UNPKG

node-calendly

Version:
114 lines 4.92 kB
"use strict"; /****************************************** * Author : Dr. Sebastian Herden * Created On : Fri Sep 16 2022 * File : ScheduledEvents.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 }); const CalendlyApiEndpoint_1 = __importDefault(require("./CalendlyApiEndpoint")); /** * The scheduled events endpoint. * @export default * @class ScheduledEvents * @extends {CalendlyApiEndpoint} * @see https://developer.calendly.com/api-docs/eb8ee72701f99-list-event-invitees */ class ScheduledEvents extends CalendlyApiEndpoint_1.default { /** * Returns a list of Events. * - Pass organization parameter to return events for that organization (requires admin/owner privilege) * - Pass user parameter to return events for a specific User * * NOTES: * * - If you are the admin/owner of the organization, you can use both organization and user to get a list of events for a specific user within your organization. * - user can only be used alone when requesting your own personal events. This will return your events within any organization that you are currently in or were a part of in the past. * @param params The request parameters. * @returns {Promise<PaginationResponse<EventDefinition> & ErrorResponse>} * @memberof ScheduledEvents * @see https://developer.calendly.com/api-docs/2d5ed9bbd2952-list-events */ listEvents(params) { return __awaiter(this, void 0, void 0, function* () { const queryParams = this.getEventsQueryParams(params); const url = `https://api.calendly.com/scheduled_events?${queryParams}`; return yield this.fetchGet(url); }); } /** * Returns a list of Invitees for an event. * @param uuid The event uuid. * @param params The request parameters. * @returns {Promise<PaginationResponse<Invitee> & ErrorResponse>} * @memberof ScheduledEvents * @see https://developer.calendly.com/api-docs/eb8ee72701f99-list-event-invitees */ listEventInvitees(uuid, params) { return __awaiter(this, void 0, void 0, function* () { const queryParams = this.getEventInviteesQueryParams(params); const url = `https://api.calendly.com/scheduled_events/${uuid}/invitees?${queryParams}`; return yield this.fetchGet(url); }); } getEventsQueryParams(params) { const queryParams = []; if (params.count) { queryParams.push(`count=${params.count}`); } if (params.invitee_email) { queryParams.push(`invitee_email=${params.invitee_email}`); } if (params.max_start_time) { queryParams.push(`max_start_time=${params.max_start_time.toISOString()}`); } if (params.min_start_time) { queryParams.push(`min_start_time=${params.min_start_time.toISOString()}`); } if (params.organization) { queryParams.push(`organization=${params.organization}`); } if (params.page_token) { queryParams.push(`page_token=${params.page_token}`); } if (params.sort) { queryParams.push(`sort=${params.sort}`); } if (params.status) { queryParams.push(`status=${params.status}`); } if (params.user) { queryParams.push(`user=${params.user}`); } return queryParams.join('&'); } getEventInviteesQueryParams(params) { const queryParams = []; if (params.count) { queryParams.push(`count=${params.count}`); } if (params.email) { queryParams.push(`email=${params.email}`); } if (params.page_token) { queryParams.push(`page_token=${params.page_token}`); } if (params.status) { queryParams.push(`status=${params.status}`); } return queryParams.join('&'); } } exports.default = ScheduledEvents; //# sourceMappingURL=ScheduledEvents.js.map