UNPKG

@gohighlevel/api-client

Version:
675 lines 26.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomFields = void 0; /** * CustomFields Service * Custom fields are data points that allow you to capture and store specific information tailored to your business requirements. You can create fields across field types like text, numeric, selection options and special fields like date/time or signature */ class CustomFields { constructor(httpClient) { this.client = httpClient; } /** * Get Custom Field / Folder By Id * <div> <p> Get Custom Field / Folder By Id.</p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async getCustomFieldById(params, options) { let url = '/custom-fields/{id}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.id !== undefined) { url = url.replace('{' + 'id' + '}', encodeURIComponent(String(params.id))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.id !== undefined) { allParams['id'] = params.id; } } 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 Custom Field By Id * <div> <p> Update Custom Field By Id </p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async updateCustomField(params, requestBody, options) { let url = '/custom-fields/{id}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.id !== undefined) { url = url.replace('{' + 'id' + '}', encodeURIComponent(String(params.id))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.id !== undefined) { allParams['id'] = params.id; } } 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 Custom Field By Id * <div> <p> Delete Custom Field By Id </p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async deleteCustomField(params, options) { let url = '/custom-fields/{id}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.id !== undefined) { url = url.replace('{' + 'id' + '}', encodeURIComponent(String(params.id))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.id !== undefined) { allParams['id'] = params.id; } } 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 Custom Fields By Object Key * <div> <p> Get Custom Fields By Object Key</p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async getCustomFieldsByObjectKey(params, options) { let url = '/custom-fields/object-key/{objectKey}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.objectKey !== undefined) { url = url.replace('{' + 'objectKey' + '}', encodeURIComponent(String(params.objectKey))); } if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.objectKey !== undefined) { allParams['objectKey'] = params.objectKey; } 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 Custom Field Folder * <div> <p> Create Custom Field Folder </p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async createCustomFieldFolder(requestBody, options) { let url = '/custom-fields/folder'; 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 Custom Field Folder Name * <div> <p> Create Custom Field Folder </p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async updateCustomFieldFolder(params, requestBody, options) { let url = '/custom-fields/folder/{id}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.id !== undefined) { url = url.replace('{' + 'id' + '}', encodeURIComponent(String(params.id))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.id !== undefined) { allParams['id'] = params.id; } } 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 Custom Field Folder * <div> <p> Create Custom Field Folder </p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async deleteCustomFieldFolder(params, options) { let url = '/custom-fields/folder/{id}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["bearer"]; if (params) { if (params.id !== undefined) { url = url.replace('{' + 'id' + '}', encodeURIComponent(String(params.id))); } if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.id !== undefined) { allParams['id'] = params.id; } if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } } 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; } /** * Create Custom Field * <div> <p> Create Custom Field </p> <div> <span style= "display: inline-block; width: 25px; height: 25px; background-color: yellow; color: black; font-weight: bold; font-size: 24px; text-align: center; line-height: 22px; border: 2px solid black; border-radius: 10%; margin-right: 10px;"> ! </span> <span> <strong> Only supports Custom Objects and Company (Business) today. Will be extended to other Standard Objects in the future. </strong> </span> </div> </div> */ async createCustomField(requestBody, options) { let url = '/custom-fields/'; 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.CustomFields = CustomFields; exports.default = CustomFields; //# sourceMappingURL=custom-fields.js.map