gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
142 lines • 6.89 kB
JavaScript
;
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.Calendar = void 0;
const axios_1 = require("axios");
const calendars_appointmentsnotes_1 = require("./calendars.appointmentsnotes");
const calendars_events_1 = require("./calendars.events");
const calendars_groups_1 = require("./calendars.groups");
const calendars_notifcations_1 = require("./calendars.notifcations");
const calendars_resources_1 = require("./calendars.resources");
class Calendar {
/**
* Endpoints For Calendars
* https://highlevel.stoplight.io/docs/integrations/db572d519b209-get-all-tasks
*/
constructor(authData) {
this.authData = authData;
this.appointmentnotes = new calendars_appointmentsnotes_1.CalendarAppointmentNote(this.authData);
this.events = new calendars_events_1.CalendarEvent(this.authData);
this.groups = new calendars_groups_1.CalendarGroup(this.authData);
this.notifications = new calendars_notifcations_1.CalendarNotification(this.authData);
this.resources = new calendars_resources_1.CalendarResource(this.authData);
}
/**
*
* Documentation - https://highlevel.stoplight.io/docs/integrations/e55dec1be7bee-get-calendars
* @param locationId
*/
getAll(locationId_1) {
return __awaiter(this, arguments, void 0, function* (locationId, showDrafted = true) {
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?locationId=${locationId}&showDrafted=${showDrafted}`, { headers });
return response.data.calendars;
});
}
/**
* Get Calendar by calendar id
* Documentation - https://highlevel.stoplight.io/docs/integrations/946f5e91e2532-get-calendar
* @param calendarId
* @returns
*/
get(calendarId) {
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/${calendarId}`, { headers });
return response.data.calendar;
});
}
/**
* Get Calendar Free Slots by calendar id
* Documentation - https://highlevel.stoplight.io/docs/integrations/7f694ee8bd969-get-free-slots
* @param calendarId
* @returns
*/
getFreeslots(calendarId_1, startDate_1, endDate_1) {
return __awaiter(this, arguments, void 0, function* (calendarId, startDate, endDate, timezone = "", userId = "userId") {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
let query = "";
if (timezone)
query += `&timezone=${timezone}`;
if (userId)
query += `&timezone=${userId}`;
const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/${calendarId}/free-slots?startDate=${startDate}&endDate=${endDate}${query}`, { headers });
return response.data.calendar;
});
}
/**
* Create Calendar
* Documentation - https://highlevel.stoplight.io/docs/integrations/db6affea7570b-create-calendar
* @param calendar
* @returns
*/
add(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`, calendar, { headers });
return response.data.calendar;
});
}
/**
* Create Block Slot
* Documentation - https://highlevel.stoplight.io/docs/integrations/5a52896a68879-create-block-slot
* @param locationId
* @param startTime
* @param endTime
* @param extra
* @returns
*/
createBlockSlot(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;
const extradata = extra ? extra : {};
const data = Object.assign({ locationId, startTime, endTime }, extradata);
const response = yield axios_1.default.post(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/events/block-slots`, data, { headers });
return response.data;
});
}
/**
* Update Calendar
* Documentation - https://highlevel.stoplight.io/docs/integrations/cf683b1696d31-update-calendar
* @param calendarId
* @param calendar
* @returns
*/
update(calendarId, 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.put(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/calendars/${calendarId}`, calendar, { headers });
return response.data.calendar;
});
}
/**
* Delete Calendar
* Documentation - https://highlevel.stoplight.io/docs/integrations/57177f7074647-delete-calendar
* @param calendarId
* @returns
*/
remove(calendarId) {
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/${calendarId}`, { headers });
return response.data.succeded;
});
}
}
exports.Calendar = Calendar;
//# sourceMappingURL=calendars.js.map