@gohighlevel/api-client
Version:
Official SDK for HighLevel Public APIs
460 lines • 17.4 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Marketplace = void 0;
/**
* Marketplace Service
* Documentation for Marketplace API
*/
class Marketplace {
constructor(httpClient) {
this.client = httpClient;
}
/**
* Create a new wallet charge
* Create a new wallet charge
*/
async charge(requestBody, options) {
let url = '/marketplace/billing/charges';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["Location-Access-Only"];
// 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;
}
/**
* Get all wallet charges
* Get all wallet charges
*/
async getCharges(params, options) {
let url = '/marketplace/billing/charges';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["Location-Access-Only"];
if (params) {
if (params.meterId !== undefined) {
queryParams['meterId'] = params.meterId;
}
if (params.eventId !== undefined) {
queryParams['eventId'] = params.eventId;
}
if (params.userId !== undefined) {
queryParams['userId'] = params.userId;
}
if (params.startDate !== undefined) {
queryParams['startDate'] = params.startDate;
}
if (params.endDate !== undefined) {
queryParams['endDate'] = params.endDate;
}
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.meterId !== undefined) {
allParams['meterId'] = params.meterId;
}
if (params.eventId !== undefined) {
allParams['eventId'] = params.eventId;
}
if (params.userId !== undefined) {
allParams['userId'] = params.userId;
}
if (params.startDate !== undefined) {
allParams['startDate'] = params.startDate;
}
if (params.endDate !== undefined) {
allParams['endDate'] = params.endDate;
}
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;
}
/**
* Delete a wallet charge
* Delete a wallet charge
*/
async deleteCharge(params, options) {
let url = '/marketplace/billing/charges/{chargeId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["Location-Access-Only"];
if (params) {
if (params.chargeId !== undefined) {
url = url.replace('{' + 'chargeId' + '}', encodeURIComponent(String(params.chargeId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.chargeId !== undefined) {
allParams['chargeId'] = params.chargeId;
}
}
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 specific wallet charge details
* Get specific wallet charge details
*/
async getSpecificCharge(params, options) {
let url = '/marketplace/billing/charges/{chargeId}';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["Location-Access-Only"];
if (params) {
if (params.chargeId !== undefined) {
url = url.replace('{' + 'chargeId' + '}', encodeURIComponent(String(params.chargeId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.chargeId !== undefined) {
allParams['chargeId'] = params.chargeId;
}
}
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;
}
/**
* Check if account has sufficient funds
* Check if account has sufficient funds
*/
async hasFunds(options) {
let url = '/marketplace/billing/charges/has-funds';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["Location-Access-Only"];
// 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;
}
/**
* Uninstall an application
* Uninstalls an application from your company or a specific location. This will remove the application`s access and stop all its functionalities
*/
async uninstallApplication(params, requestBody, options) {
let url = '/marketplace/app/{appId}/installations';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = ["Location-Access-Only", "Agency-Access"];
if (params) {
if (params.appId !== undefined) {
url = url.replace('{' + 'appId' + '}', encodeURIComponent(String(params.appId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.appId !== undefined) {
allParams['appId'] = params.appId;
}
}
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, options?.preferredTokenType);
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 Installer Details
* Fetches installer details for the authenticated user. This endpoint returns information about the company, location, user, and installation details associated with the current OAuth token.
*/
async getInstallerDetails(params, options) {
let url = '/marketplace/app/{appId}/installations';
const queryParams = {};
const headerParams = {};
// Extract security requirements for this endpoint
const securityRequirements = [];
if (params) {
if (params.appId !== undefined) {
url = url.replace('{' + 'appId' + '}', encodeURIComponent(String(params.appId)));
}
}
// Collect all parameters for token resolution (including path params)
const allParams = {};
if (params) {
if (params.appId !== undefined) {
allParams['appId'] = params.appId;
}
}
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;
}
}
exports.Marketplace = Marketplace;
exports.default = Marketplace;
//# sourceMappingURL=marketplace.js.map