UNPKG

node-calendly

Version:
103 lines 4.37 kB
"use strict"; /****************************************** * Author : Dr. Sebastian Herden * Created On : Fri Sep 16 2022 * File : ActivityLog.ts *******************************************/ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ActivityLogQuery = void 0; const CalendlyApiEndpointWithOrganization_1 = __importDefault(require("./CalendlyApiEndpointWithOrganization")); /** * The activity log endpoint. * @export default * @class ActivityLog * @extends {CalendlyApiEndpointWithOrganization} * @see https://developer.calendly.com/api-docs/d37c7f031f339-list-activity-log-entries */ class ActivityLog extends CalendlyApiEndpointWithOrganization_1.default { /** * Returns a list of activity log entries * @param params The query parameters. * @returns {Promise<ActivityLogResponse>} It is either a list of activity log entries as a paginated response or an error. * @see https://developer.calendly.com/api-docs/d37c7f031f339-list-activity-log-entries * @memberof ActivityLog * @example const activitiesResponse = Calendly.activityLog.listActivityLogEntries({count: 10}); * @see ActivityLogQueryParams * @see ActivityLogResponse */ listActivityLogEntries(params) { return __awaiter(this, void 0, void 0, function* () { const query = new ActivityLogQuery(params, yield this.organizationProvider.getOrganizationUri()); const queryParams = query.getQueryParams(); const url = `https://api.calendly.com/activity_log_entries?${queryParams}`; return yield this.fetchGet(url); }); } } exports.default = ActivityLog; /** * The definition of an Activity Log entry. * @export * @class ActivityLogQuery * @see https://developer.calendly.com/api-docs/d37c7f031f339-list-activity-log-entries */ class ActivityLogQuery { constructor(data, organization) { this.organization = organization; this.action = data.action; this.count = data.count ? data.count : 20; this.max_occurred_at = data.max_occurred_at; this.min_occurred_at = data.min_occurred_at; this.namespace = data.namespace; this.page_token = data.page_token; this.search_term = data.search_term; this.sort = data.sort; } /** * Returns the query parameters as a string. * @returns {string} The query string for the request. */ getQueryParams() { const queryParams = []; queryParams.push(`organization=${this.organization}`); if (this.action) { queryParams.push(`action=${this.action.join(',')}`); } if (this.count) { queryParams.push(`count=${this.count}`); } if (this.max_occurred_at) { queryParams.push(`max_occurred_at=${this.max_occurred_at.toISOString()}`); } if (this.min_occurred_at) { queryParams.push(`min_occurred_at=${this.min_occurred_at.toISOString()}`); } if (this.namespace) { queryParams.push(`namespace=${this.namespace.join(',')}`); } if (this.page_token) { queryParams.push(`page_token=${this.page_token}`); } if (this.search_term) { queryParams.push(`search_term=${this.search_term}`); } if (this.sort) { queryParams.push(`sort=${this.sort}`); } return queryParams.join('&'); } } exports.ActivityLogQuery = ActivityLogQuery; //# sourceMappingURL=ActivityLog.js.map