@gohighlevel/api-client
Version:
Official SDK for HighLevel Public APIs
397 lines • 14.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Links = void 0;
/**
* Links Service
* Documentation for links API
*/
class Links {
constructor(httpClient) {
this.client = httpClient;
}
/**
* Get Link by ID
* Get a single link by its ID
*/
async getLinkById(params, options) {
let url = '/links/id/{linkId}';
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.linkId !== undefined) {
url = url.replace('{' + 'linkId' + '}', encodeURIComponent(String(params.linkId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.locationId !== undefined) {
allParams['locationId'] = params.locationId;
}
if (params.linkId !== undefined) {
allParams['linkId'] = params.linkId;
}
}
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 Link
* Update Link
*/
async updateLink(params, requestBody, options) {
let url = '/links/{linkId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.linkId !== undefined) {
url = url.replace('{' + 'linkId' + '}', encodeURIComponent(String(params.linkId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.linkId !== undefined) {
allParams['linkId'] = params.linkId;
}
}
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 Link
* Delete Link
*/
async deleteLink(params, options) {
let url = '/links/{linkId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["bearer"];
if (params) {
if (params.linkId !== undefined) {
url = url.replace('{' + 'linkId' + '}', encodeURIComponent(String(params.linkId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.linkId !== undefined) {
allParams['linkId'] = params.linkId;
}
}
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;
}
/**
* Search Trigger Links
* Get list of links by searching
*/
async searchTriggerLinks(params, options) {
let url = '/links/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.query !== undefined) {
queryParams['query'] = params.query;
}
if (params.skip !== undefined) {
queryParams['skip'] = params.skip;
}
if (params.limit !== undefined) {
queryParams['limit'] = params.limit;
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.locationId !== undefined) {
allParams['locationId'] = params.locationId;
}
if (params.query !== undefined) {
allParams['query'] = params.query;
}
if (params.skip !== undefined) {
allParams['skip'] = params.skip;
}
if (params.limit !== undefined) {
allParams['limit'] = params.limit;
}
}
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 Links
* Get Links
*/
async getLinks(params, options) {
let url = '/links/';
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 Link
* Create Link
*/
async createLink(requestBody, options) {
let url = '/links/';
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.Links = Links;
exports.default = Links;
//# sourceMappingURL=links.js.map