UNPKG

@gohighlevel/api-client

Version:
1,246 lines 48.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Conversations = void 0; /** * Conversations Service * Documentation for Conversations API */ class Conversations { constructor(httpClient) { this.client = httpClient; } /** * Search Conversations * Returns a list of all conversations matching the search criteria along with the sort and filter options selected. */ async searchConversation(params, options) { let url = '/conversations/search'; 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.contactId !== undefined) { queryParams['contactId'] = params.contactId; } if (params.assignedTo !== undefined) { queryParams['assignedTo'] = params.assignedTo; } if (params.followers !== undefined) { queryParams['followers'] = params.followers; } if (params.mentions !== undefined) { queryParams['mentions'] = params.mentions; } if (params.query !== undefined) { queryParams['query'] = params.query; } if (params.sort !== undefined) { queryParams['sort'] = params.sort; } if (params.startAfterDate !== undefined) { queryParams['startAfterDate'] = params.startAfterDate; } if (params.id !== undefined) { queryParams['id'] = params.id; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.lastMessageType !== undefined) { queryParams['lastMessageType'] = params.lastMessageType; } if (params.lastMessageAction !== undefined) { queryParams['lastMessageAction'] = params.lastMessageAction; } if (params.lastMessageDirection !== undefined) { queryParams['lastMessageDirection'] = params.lastMessageDirection; } if (params.status !== undefined) { queryParams['status'] = params.status; } if (params.sortBy !== undefined) { queryParams['sortBy'] = params.sortBy; } if (params.sortScoreProfile !== undefined) { queryParams['sortScoreProfile'] = params.sortScoreProfile; } if (params.scoreProfile !== undefined) { queryParams['scoreProfile'] = params.scoreProfile; } if (params.scoreProfileMin !== undefined) { queryParams['scoreProfileMin'] = params.scoreProfileMin; } if (params.scoreProfileMax !== undefined) { queryParams['scoreProfileMax'] = params.scoreProfileMax; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.contactId !== undefined) { allParams['contactId'] = params.contactId; } if (params.assignedTo !== undefined) { allParams['assignedTo'] = params.assignedTo; } if (params.followers !== undefined) { allParams['followers'] = params.followers; } if (params.mentions !== undefined) { allParams['mentions'] = params.mentions; } if (params.query !== undefined) { allParams['query'] = params.query; } if (params.sort !== undefined) { allParams['sort'] = params.sort; } if (params.startAfterDate !== undefined) { allParams['startAfterDate'] = params.startAfterDate; } if (params.id !== undefined) { allParams['id'] = params.id; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.lastMessageType !== undefined) { allParams['lastMessageType'] = params.lastMessageType; } if (params.lastMessageAction !== undefined) { allParams['lastMessageAction'] = params.lastMessageAction; } if (params.lastMessageDirection !== undefined) { allParams['lastMessageDirection'] = params.lastMessageDirection; } if (params.status !== undefined) { allParams['status'] = params.status; } if (params.sortBy !== undefined) { allParams['sortBy'] = params.sortBy; } if (params.sortScoreProfile !== undefined) { allParams['sortScoreProfile'] = params.sortScoreProfile; } if (params.scoreProfile !== undefined) { allParams['scoreProfile'] = params.scoreProfile; } if (params.scoreProfileMin !== undefined) { allParams['scoreProfileMin'] = params.scoreProfileMin; } if (params.scoreProfileMax !== undefined) { allParams['scoreProfileMax'] = params.scoreProfileMax; } } 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 Conversation * Get the conversation details based on the conversation ID */ async getConversation(params, options) { let url = '/conversations/{conversationId}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.conversationId !== undefined) { url = url.replace('{' + 'conversationId' + '}', encodeURIComponent(String(params.conversationId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.conversationId !== undefined) { allParams['conversationId'] = params.conversationId; } } 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 Conversation * Update the conversation details based on the conversation ID */ async updateConversation(params, requestBody, options) { let url = '/conversations/{conversationId}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.conversationId !== undefined) { url = url.replace('{' + 'conversationId' + '}', encodeURIComponent(String(params.conversationId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.conversationId !== undefined) { allParams['conversationId'] = params.conversationId; } } 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; } /** * Delete Conversation * Delete the conversation details based on the conversation ID */ async deleteConversation(params, options) { let url = '/conversations/{conversationId}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.conversationId !== undefined) { url = url.replace('{' + 'conversationId' + '}', encodeURIComponent(String(params.conversationId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.conversationId !== undefined) { allParams['conversationId'] = params.conversationId; } } 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; } /** * Get email by Id * Get email by Id */ async getEmailById(options) { let url = '/conversations/messages/email/{id}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = []; // Collect all parameters for token resolution (including path params) const allParams = {}; 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; } /** * Cancel a scheduled email message. * Post the messageId for the API to delete a scheduled email message. <br /> */ async cancelScheduledEmailMessage(params, options) { let url = '/conversations/messages/email/{emailMessageId}/schedule'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = []; if (params) { if (params.emailMessageId !== undefined) { url = url.replace('{' + 'emailMessageId' + '}', encodeURIComponent(String(params.emailMessageId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.emailMessageId !== undefined) { allParams['emailMessageId'] = params.emailMessageId; } } 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; } /** * Get message by message id * Get message by message id. */ async getMessage(options) { let url = '/conversations/messages/{id}'; 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: '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 messages by conversation id * Get messages by conversation id. */ async getMessages(params, options) { let url = '/conversations/{conversationId}/messages'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.conversationId !== undefined) { url = url.replace('{' + 'conversationId' + '}', encodeURIComponent(String(params.conversationId))); } if (params.lastMessageId !== undefined) { queryParams['lastMessageId'] = params.lastMessageId; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.type !== undefined) { queryParams['type'] = params.type; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.conversationId !== undefined) { allParams['conversationId'] = params.conversationId; } if (params.lastMessageId !== undefined) { allParams['lastMessageId'] = params.lastMessageId; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.type !== undefined) { allParams['type'] = params.type; } } 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; } /** * Send a new message * Post the necessary fields for the API to send a new message. */ async sendANewMessage(requestBody, options) { let url = '/conversations/messages'; 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; } /** * Add an inbound message * Post the necessary fields for the API to add a new inbound message. <br /> */ async addAnInboundMessage(requestBody, options) { let url = '/conversations/messages/inbound'; 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; } /** * Add an external outbound call * Post the necessary fields for the API to add a new outbound call. */ async addAnOutboundMessage(requestBody, options) { let url = '/conversations/messages/outbound'; 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; } /** * Cancel a scheduled message. * Post the messageId for the API to delete a scheduled message. <br /> */ async cancelScheduledMessage(params, options) { let url = '/conversations/messages/{messageId}/schedule'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.messageId !== undefined) { url = url.replace('{' + 'messageId' + '}', encodeURIComponent(String(params.messageId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.messageId !== undefined) { allParams['messageId'] = params.messageId; } } 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; } /** * Upload file attachments * Post the necessary fields for the API to upload files. The files need to be a buffer with the key "fileAttachment". <br /><br /> The allowed file types are: <br/> <ul><li>JPG</li><li>JPEG</li><li>PNG</li><li>MP4</li><li>MPEG</li><li>ZIP</li><li>RAR</li><li>PDF</li><li>DOC</li><li>DOCX</li><li>TXT</li><li>MP3</li><li>WAV</li></ul> <br /><br /> The API will return an object with the URLs */ async uploadFileAttachments(requestBody, options) { let url = '/conversations/messages/upload'; 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 message status * Post the necessary fields for the API to update message status. */ async updateMessageStatus(params, requestBody, options) { let url = '/conversations/messages/{messageId}/status'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.messageId !== undefined) { url = url.replace('{' + 'messageId' + '}', encodeURIComponent(String(params.messageId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.messageId !== undefined) { allParams['messageId'] = params.messageId; } } 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 Recording by Message ID * Get the recording for a message by passing the message id */ async getMessageRecording(params, options) { let url = '/conversations/messages/{messageId}/locations/{locationId}/recording'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer", "Location-Access"]; if (params) { if (params.locationId !== undefined) { url = url.replace('{' + 'locationId' + '}', encodeURIComponent(String(params.locationId))); } if (params.messageId !== undefined) { url = url.replace('{' + 'messageId' + '}', encodeURIComponent(String(params.messageId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.messageId !== undefined) { allParams['messageId'] = params.messageId; } } 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 transcription by Message ID * Get the recording transcription for a message by passing the message id */ async getMessageTranscription(params, options) { let url = '/conversations/locations/{locationId}/messages/{messageId}/transcription'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer", "Location-Access"]; if (params) { if (params.locationId !== undefined) { url = url.replace('{' + 'locationId' + '}', encodeURIComponent(String(params.locationId))); } if (params.messageId !== undefined) { url = url.replace('{' + 'messageId' + '}', encodeURIComponent(String(params.messageId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.messageId !== undefined) { allParams['messageId'] = params.messageId; } } 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; } /** * Download transcription by Message ID * Download the recording transcription for a message by passing the message id */ async downloadMessageTranscription(params, options) { let url = '/conversations/locations/{locationId}/messages/{messageId}/transcription/download'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer", "Location-Access"]; if (params) { if (params.locationId !== undefined) { url = url.replace('{' + 'locationId' + '}', encodeURIComponent(String(params.locationId))); } if (params.messageId !== undefined) { url = url.replace('{' + 'messageId' + '}', encodeURIComponent(String(params.messageId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.messageId !== undefined) { allParams['messageId'] = params.messageId; } } 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; } /** * Agent/Ai-Bot is typing a message indicator for live chat * Agent/AI-Bot will call this when they are typing a message in live chat message */ async liveChatAgentTyping(requestBody, options) { let url = '/conversations/providers/live-chat/typing'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; // 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; } /** * Create Conversation * Creates a new conversation with the data provided */ async createConversation(requestBody, options) { let url = '/conversations/'; 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; } } exports.Conversations = Conversations; exports.default = Conversations; //# sourceMappingURL=conversations.js.map