UNPKG

gohl

Version:

Go Highlevel Node Js ease of use library implementation to their API

149 lines 6.96 kB
"use strict"; 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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CalendarEvent = void 0; const axios_1 = require("axios"); class CalendarEvent { /** * Endpoints For Calendar Events and Appointments * https://highlevel.stoplight.io/docs/integrations/a83f44a3112a4-get-calendar-events */ constructor(authData) { this.authData = authData; } /** * Get Calendar Events * Documentation - https://highlevel.stoplight.io/docs/integrations/a83f44a3112a4-get-calendar-events * @param locationId * @param startTime * @param endTime * @param extra */ getAll(locationId, startTime, endTime, extra) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; let query = ''; if (extra) { if (extra.userId) query += `&userId=${extra.userId}`; if (extra.groupId) query += `&groupId=${extra.groupId}`; if (extra.calendarId) query += `&calendarId=${extra.calendarId}`; } const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events?locationId=${locationId}&startTime=${startTime}&endTime=${endTime}${query}`, { headers }); return response.data.events; }); } /** * Get Calendar Block Slots * Documentation - http://highlevel.stoplight.io/docs/integrations/e31320c70cfde-get-blocked-slots * @param locationId * @param startTime * @param endTime * @param extra */ getBlockSlots(locationId, startTime, endTime, extra) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; let query = ''; if (extra) { if (extra.userId) query += `&userId=${extra.userId}`; if (extra.groupId) query += `&groupId=${extra.groupId}`; if (extra.calendarId) query += `&calendarId=${extra.calendarId}`; } const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/blocked-slots?locationId=${locationId}&startTime=${startTime}&endTime=${endTime}${query}`, { headers }); return response.data.events; }); } /** * Get Appointments * Documentation - https://highlevel.stoplight.io/docs/integrations/bc4114ff64e38-get-appointment * @param eventId - Event Id or Instance id. For recurring appointments send masterEventId to modify original series. * @returns */ getAppointments(eventId) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events/appointments/${eventId}`, { headers }); return response.data.event; }); } /** * Create Appointment * Documentation - http://highlevel.stoplight.io/docs/integrations/a192f863cad27-create-appointment * @param locationId * @param contactId * @param startTime * @param calendar * @returns */ addAppointment(locationId, contactId, startTime, calendar) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; const response = yield axios_1.default.post(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events/appointments`, Object.assign(Object.assign({ locationId, contactId }, calendar), { startTime }), { headers }); return response.data; }); } /** * Update Appointment * Documentation - https://highlevel.stoplight.io/docs/integrations/3a1380a3a9df8-update-appointment * @param eventId * @param event * @returns */ updateAppointment(eventId, event) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; const response = yield axios_1.default.put(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events/appointments/${eventId}`, event, { headers }); return response.data; }); } /** * Update Block Slot - Update block slot by ID * Documentation - https://highlevel.stoplight.io/docs/integrations/098186acbb8db-update-block-slot * @param eventId * @param event * @returns */ updateBlockSlot(eventId, slot) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; const response = yield axios_1.default.put(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events/block-slots/${eventId}`, slot, { headers }); return response.data; }); } /** * Delete Event * Documentation - https://highlevel.stoplight.io/docs/integrations/96b85108e6d3b-delete-event * @param eventId * @returns */ remove(eventId) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers; const response = yield axios_1.default.delete(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events/${eventId}`, { headers }); return response.data.succeded; }); } } exports.CalendarEvent = CalendarEvent; //# sourceMappingURL=calendars.events.js.map