@gohighlevel/api-client
Version:
Official SDK for HighLevel Public APIs
1,345 lines • 84.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Calendars = void 0;
/**
* Calendars Service
* Documentation for Calendars API
*/
class Calendars {
constructor(httpClient) {
this.client = httpClient;
}
/**
* Get Groups
* Get all calendar groups in a location.
*/
async getGroups(params, options) {
let url = '/calendars/groups';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.locationId !== undefined) {
queryParams['locationId'] = params.locationId;
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.locationId !== undefined) {
allParams['locationId'] = params.locationId;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Create Calendar Group
* Create Calendar Group
*/
async createCalendarGroup(requestBody, options) {
let url = '/calendars/groups';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
// Collect all parameters for token resolution (including path params)
const allParams = {};
const config = {
method: 'POST',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Validate group slug
* Validate if group slug is available or not.
*/
async validateGroupsSlug(requestBody, options) {
let url = '/calendars/groups/validate-slug';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
// Collect all parameters for token resolution (including path params)
const allParams = {};
const config = {
method: 'POST',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Delete Group
* Delete Group
*/
async deleteGroup(params, options) {
let url = '/calendars/groups/{groupId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.groupId !== undefined) {
url = url.replace('{' + 'groupId' + '}', encodeURIComponent(String(params.groupId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.groupId !== undefined) {
allParams['groupId'] = params.groupId;
}
}
const config = {
method: 'DELETE',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Update Group
* Update Group by group ID
*/
async editGroup(params, requestBody, options) {
let url = '/calendars/groups/{groupId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.groupId !== undefined) {
url = url.replace('{' + 'groupId' + '}', encodeURIComponent(String(params.groupId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.groupId !== undefined) {
allParams['groupId'] = params.groupId;
}
}
const config = {
method: 'PUT',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Disable Group
* Disable Group
*/
async disableGroup(params, requestBody, options) {
let url = '/calendars/groups/{groupId}/status';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.groupId !== undefined) {
url = url.replace('{' + 'groupId' + '}', encodeURIComponent(String(params.groupId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.groupId !== undefined) {
allParams['groupId'] = params.groupId;
}
}
const config = {
method: 'PUT',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Create appointment
* Create appointment
*/
async createAppointment(requestBody, options) {
let url = '/calendars/events/appointments';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
// Collect all parameters for token resolution (including path params)
const allParams = {};
const config = {
method: 'POST',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Update Appointment
* Update appointment
*/
async editAppointment(params, requestBody, options) {
let url = '/calendars/events/appointments/{eventId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.eventId !== undefined) {
url = url.replace('{' + 'eventId' + '}', encodeURIComponent(String(params.eventId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.eventId !== undefined) {
allParams['eventId'] = params.eventId;
}
}
const config = {
method: 'PUT',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Get Appointment
* Get appointment by ID
*/
async getAppointment(params, options) {
let url = '/calendars/events/appointments/{eventId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.eventId !== undefined) {
url = url.replace('{' + 'eventId' + '}', encodeURIComponent(String(params.eventId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.eventId !== undefined) {
allParams['eventId'] = params.eventId;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Get Calendar Events
* Get Calendar Events
*/
async getCalendarEvents(params, options) {
let url = '/calendars/events';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.locationId !== undefined) {
queryParams['locationId'] = params.locationId;
}
if (params.userId !== undefined) {
queryParams['userId'] = params.userId;
}
if (params.calendarId !== undefined) {
queryParams['calendarId'] = params.calendarId;
}
if (params.groupId !== undefined) {
queryParams['groupId'] = params.groupId;
}
if (params.startTime !== undefined) {
queryParams['startTime'] = params.startTime;
}
if (params.endTime !== undefined) {
queryParams['endTime'] = params.endTime;
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.locationId !== undefined) {
allParams['locationId'] = params.locationId;
}
if (params.userId !== undefined) {
allParams['userId'] = params.userId;
}
if (params.calendarId !== undefined) {
allParams['calendarId'] = params.calendarId;
}
if (params.groupId !== undefined) {
allParams['groupId'] = params.groupId;
}
if (params.startTime !== undefined) {
allParams['startTime'] = params.startTime;
}
if (params.endTime !== undefined) {
allParams['endTime'] = params.endTime;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Get Blocked Slots
* Get Blocked Slots
*/
async getBlockedSlots(params, options) {
let url = '/calendars/blocked-slots';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.locationId !== undefined) {
queryParams['locationId'] = params.locationId;
}
if (params.userId !== undefined) {
queryParams['userId'] = params.userId;
}
if (params.calendarId !== undefined) {
queryParams['calendarId'] = params.calendarId;
}
if (params.groupId !== undefined) {
queryParams['groupId'] = params.groupId;
}
if (params.startTime !== undefined) {
queryParams['startTime'] = params.startTime;
}
if (params.endTime !== undefined) {
queryParams['endTime'] = params.endTime;
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.locationId !== undefined) {
allParams['locationId'] = params.locationId;
}
if (params.userId !== undefined) {
allParams['userId'] = params.userId;
}
if (params.calendarId !== undefined) {
allParams['calendarId'] = params.calendarId;
}
if (params.groupId !== undefined) {
allParams['groupId'] = params.groupId;
}
if (params.startTime !== undefined) {
allParams['startTime'] = params.startTime;
}
if (params.endTime !== undefined) {
allParams['endTime'] = params.endTime;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Create Block Slot
* Create block slot
*/
async createBlockSlot(requestBody, options) {
let url = '/calendars/events/block-slots';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
// Collect all parameters for token resolution (including path params)
const allParams = {};
const config = {
method: 'POST',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Update Block Slot
* Update block slot by ID
*/
async editBlockSlot(params, requestBody, options) {
let url = '/calendars/events/block-slots/{eventId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.eventId !== undefined) {
url = url.replace('{' + 'eventId' + '}', encodeURIComponent(String(params.eventId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.eventId !== undefined) {
allParams['eventId'] = params.eventId;
}
}
const config = {
method: 'PUT',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Get Free Slots
* Get free slots for a calendar between a date range. Optionally a consumer can also request free slots in a particular timezone and also for a particular user.
*/
async getSlots(params, options) {
let url = '/calendars/{calendarId}/free-slots';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.calendarId !== undefined) {
url = url.replace('{' + 'calendarId' + '}', encodeURIComponent(String(params.calendarId)));
}
if (params.startDate !== undefined) {
queryParams['startDate'] = params.startDate;
}
if (params.endDate !== undefined) {
queryParams['endDate'] = params.endDate;
}
if (params.timezone !== undefined) {
queryParams['timezone'] = params.timezone;
}
if (params.userId !== undefined) {
queryParams['userId'] = params.userId;
}
if (params.userIds !== undefined) {
queryParams['userIds'] = params.userIds;
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.calendarId !== undefined) {
allParams['calendarId'] = params.calendarId;
}
if (params.startDate !== undefined) {
allParams['startDate'] = params.startDate;
}
if (params.endDate !== undefined) {
allParams['endDate'] = params.endDate;
}
if (params.timezone !== undefined) {
allParams['timezone'] = params.timezone;
}
if (params.userId !== undefined) {
allParams['userId'] = params.userId;
}
if (params.userIds !== undefined) {
allParams['userIds'] = params.userIds;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Update Calendar
* Update calendar by ID.
*/
async updateCalendar(params, requestBody, options) {
let url = '/calendars/{calendarId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.calendarId !== undefined) {
url = url.replace('{' + 'calendarId' + '}', encodeURIComponent(String(params.calendarId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.calendarId !== undefined) {
allParams['calendarId'] = params.calendarId;
}
}
const config = {
method: 'PUT',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Get Calendar
* Get calendar by ID
*/
async getCalendar(params, options) {
let url = '/calendars/{calendarId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.calendarId !== undefined) {
url = url.replace('{' + 'calendarId' + '}', encodeURIComponent(String(params.calendarId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.calendarId !== undefined) {
allParams['calendarId'] = params.calendarId;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Delete Calendar
* Delete calendar by ID
*/
async deleteCalendar(params, options) {
let url = '/calendars/{calendarId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.calendarId !== undefined) {
url = url.replace('{' + 'calendarId' + '}', encodeURIComponent(String(params.calendarId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.calendarId !== undefined) {
allParams['calendarId'] = params.calendarId;
}
}
const config = {
method: 'DELETE',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Delete Event
* Delete event by ID
*/
async deleteEvent(params, requestBody, options) {
let url = '/calendars/events/{eventId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.eventId !== undefined) {
url = url.replace('{' + 'eventId' + '}', encodeURIComponent(String(params.eventId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.eventId !== undefined) {
allParams['eventId'] = params.eventId;
}
}
const config = {
method: 'DELETE',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Get Notes
* Get Appointment Notes
*/
async getAppointmentNotes(params, options) {
let url = '/calendars/appointments/{appointmentId}/notes';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.limit !== undefined) {
queryParams['limit'] = params.limit;
}
if (params.offset !== undefined) {
queryParams['offset'] = params.offset;
}
if (params.appointmentId !== undefined) {
url = url.replace('{' + 'appointmentId' + '}', encodeURIComponent(String(params.appointmentId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.limit !== undefined) {
allParams['limit'] = params.limit;
}
if (params.offset !== undefined) {
allParams['offset'] = params.offset;
}
if (params.appointmentId !== undefined) {
allParams['appointmentId'] = params.appointmentId;
}
}
const config = {
method: 'GET',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, {});
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Create Note
* Create Note
*/
async createAppointmentNote(params, requestBody, options) {
let url = '/calendars/appointments/{appointmentId}/notes';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.appointmentId !== undefined) {
url = url.replace('{' + 'appointmentId' + '}', encodeURIComponent(String(params.appointmentId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.appointmentId !== undefined) {
allParams['appointmentId'] = params.appointmentId;
}
}
const config = {
method: 'POST',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...options?.headers
};
// Combine queryParams with allParams for token resolution
const combinedQuery = {
...queryParams,
...allParams
};
const authToken = await ghlInstance.getTokenForSecurity(securityRequirements, combinedHeaders, combinedQuery, requestBody);
if (authToken) {
config.headers = {
...config.headers,
'Authorization': authToken
};
}
}
catch (error) {
throw error; // Re-throw authentication errors
}
}
const response = await this.client.request(config);
return response.data;
}
/**
* Update Note
* Update Note
*/
async updateAppointmentNote(params, requestBody, options) {
let url = '/calendars/appointments/{appointmentId}/notes/{noteId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.appointmentId !== undefined) {
url = url.replace('{' + 'appointmentId' + '}', encodeURIComponent(String(params.appointmentId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.appointmentId !== undefined) {
allParams['appointmentId'] = params.appointmentId;
}
}
const config = {
method: 'PUT',
url,
params: queryParams,
headers: {
...headerParams,
...options?.headers
},
data: requestBody,
...options
};
// Get appropriate authorization token based on security requirements
const ghlInstance = this.client.__ghlInstance;
if (ghlInstance && typeof ghlInstance.getTokenForSecurity === 'function') {
try {
// Combine headerParams with headers from options
const combinedHeaders = {
...headerParams,
...opti