UNPKG

@gohighlevel/api-client

Version:
1,243 lines 71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Payments = void 0; /** * Payments Service * Documentation for payments API */ class Payments { constructor(httpClient) { this.client = httpClient; } /** * Create White-label Integration Provider * The "Create White-label Integration Provider" API allows adding a new payment provider integration to the system which is built on top of Authorize.net or NMI. Use this endpoint to create a integration provider with the specified details. Ensure that the required information is provided in the request payload. This endpoint can be only invoked using marketplace-app token */ async createIntegrationProvider(requestBody, options) { let url = '/payments/integrations/provider/whitelabel'; 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; } /** * List White-label Integration Providers * The "List White-label Integration Providers" API allows to retrieve a paginated list of integration providers. Customize your results by filtering whitelabel integration providers(which are built directly on top of Authorize.net or NMI) based on name or paginate through the list using the provided query parameters. This endpoint provides a straightforward way to explore and retrieve integration provider information. */ async listIntegrationProviders(params, options) { let url = '/payments/integrations/provider/whitelabel'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.offset !== undefined) { queryParams['offset'] = params.offset; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.offset !== undefined) { allParams['offset'] = params.offset; } } 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; } /** * List Orders * The "List Orders" API allows to retrieve a paginated list of orders. Customize your results by filtering orders based on name, alt type, order status, payment mode, date range, type of source, contact, funnel products or paginate through the list using the provided query parameters. This endpoint provides a straightforward way to explore and retrieve order information. */ async listOrders(params, options) { let url = '/payments/orders'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.status !== undefined) { queryParams['status'] = params.status; } if (params.paymentMode !== undefined) { queryParams['paymentMode'] = params.paymentMode; } if (params.startAt !== undefined) { queryParams['startAt'] = params.startAt; } if (params.endAt !== undefined) { queryParams['endAt'] = params.endAt; } if (params.search !== undefined) { queryParams['search'] = params.search; } if (params.contactId !== undefined) { queryParams['contactId'] = params.contactId; } if (params.funnelProductIds !== undefined) { queryParams['funnelProductIds'] = params.funnelProductIds; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.offset !== undefined) { queryParams['offset'] = params.offset; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.status !== undefined) { allParams['status'] = params.status; } if (params.paymentMode !== undefined) { allParams['paymentMode'] = params.paymentMode; } if (params.startAt !== undefined) { allParams['startAt'] = params.startAt; } if (params.endAt !== undefined) { allParams['endAt'] = params.endAt; } if (params.search !== undefined) { allParams['search'] = params.search; } if (params.contactId !== undefined) { allParams['contactId'] = params.contactId; } if (params.funnelProductIds !== undefined) { allParams['funnelProductIds'] = params.funnelProductIds; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.offset !== undefined) { allParams['offset'] = params.offset; } } 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 Order by ID * The "Get Order by ID" API allows to retrieve information for a specific order using its unique identifier. Use this endpoint to fetch details for a single order based on the provided order ID. */ async getOrderById(params, options) { let url = '/payments/orders/{orderId}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.orderId !== undefined) { url = url.replace('{' + 'orderId' + '}', encodeURIComponent(String(params.orderId))); } if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } if (params.altId !== undefined) { queryParams['altId'] = params.altId; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.orderId !== undefined) { allParams['orderId'] = params.orderId; } if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.altId !== undefined) { allParams['altId'] = params.altId; } } 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; } /** * Record Order Payment * The "Record Order Payment" API allows to record a payment for an order. Use this endpoint to record payment for an order and update the order status to "Paid". */ async recordOrderPayment(params, requestBody, options) { let url = '/payments/orders/{orderId}/record-payment'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.orderId !== undefined) { url = url.replace('{' + 'orderId' + '}', encodeURIComponent(String(params.orderId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.orderId !== undefined) { allParams['orderId'] = params.orderId; } } 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; } /** * migration Endpoint for Order Payment Status * Process to migrate all the older orders and based on the statuses introduce the payment statuses as well */ async postMigrateOrderPaymentStatus(params, options) { let url = '/payments/orders/migrate-order-ps'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } if (params.altId !== undefined) { queryParams['altId'] = params.altId; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.altId !== undefined) { allParams['altId'] = params.altId; } } const config = { method: 'POST', 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 order fulfillment * The "Order Fulfillment" API facilitates the process of fulfilling an order. */ async createOrderFulfillment(params, requestBody, options) { let url = '/payments/orders/{orderId}/fulfillments'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.orderId !== undefined) { url = url.replace('{' + 'orderId' + '}', encodeURIComponent(String(params.orderId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.orderId !== undefined) { allParams['orderId'] = params.orderId; } } 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; } /** * List fulfillment * List all fulfillment history of an order */ async listOrderFulfillment(params, options) { let url = '/payments/orders/{orderId}/fulfillments'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.orderId !== undefined) { url = url.replace('{' + 'orderId' + '}', encodeURIComponent(String(params.orderId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.orderId !== undefined) { allParams['orderId'] = params.orderId; } } 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; } /** * List Order Notes * List all notes of an order */ async listOrderNotes(params, options) { let url = '/payments/orders/{orderId}/notes'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.orderId !== undefined) { url = url.replace('{' + 'orderId' + '}', encodeURIComponent(String(params.orderId))); } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.orderId !== undefined) { allParams['orderId'] = params.orderId; } } 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; } /** * List Transactions * The "List Transactions" API allows to retrieve a paginated list of transactions. Customize your results by filtering transactions based on name, alt type, transaction status, payment mode, date range, type of source, contact, subscription id, entity id or paginate through the list using the provided query parameters. This endpoint provides a straightforward way to explore and retrieve transaction information. */ async listTransactions(params, options) { let url = '/payments/transactions'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.paymentMode !== undefined) { queryParams['paymentMode'] = params.paymentMode; } if (params.startAt !== undefined) { queryParams['startAt'] = params.startAt; } if (params.endAt !== undefined) { queryParams['endAt'] = params.endAt; } if (params.entitySourceType !== undefined) { queryParams['entitySourceType'] = params.entitySourceType; } if (params.entitySourceSubType !== undefined) { queryParams['entitySourceSubType'] = params.entitySourceSubType; } if (params.search !== undefined) { queryParams['search'] = params.search; } if (params.subscriptionId !== undefined) { queryParams['subscriptionId'] = params.subscriptionId; } if (params.entityId !== undefined) { queryParams['entityId'] = params.entityId; } if (params.contactId !== undefined) { queryParams['contactId'] = params.contactId; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.offset !== undefined) { queryParams['offset'] = params.offset; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.paymentMode !== undefined) { allParams['paymentMode'] = params.paymentMode; } if (params.startAt !== undefined) { allParams['startAt'] = params.startAt; } if (params.endAt !== undefined) { allParams['endAt'] = params.endAt; } if (params.entitySourceType !== undefined) { allParams['entitySourceType'] = params.entitySourceType; } if (params.entitySourceSubType !== undefined) { allParams['entitySourceSubType'] = params.entitySourceSubType; } if (params.search !== undefined) { allParams['search'] = params.search; } if (params.subscriptionId !== undefined) { allParams['subscriptionId'] = params.subscriptionId; } if (params.entityId !== undefined) { allParams['entityId'] = params.entityId; } if (params.contactId !== undefined) { allParams['contactId'] = params.contactId; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.offset !== undefined) { allParams['offset'] = params.offset; } } 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 Transaction by ID * The "Get Transaction by ID" API allows to retrieve information for a specific transaction using its unique identifier. Use this endpoint to fetch details for a single transaction based on the provided transaction ID. */ async getTransactionById(params, options) { let url = '/payments/transactions/{transactionId}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.transactionId !== undefined) { url = url.replace('{' + 'transactionId' + '}', encodeURIComponent(String(params.transactionId))); } if (params.locationId !== undefined) { queryParams['locationId'] = params.locationId; } if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.transactionId !== undefined) { allParams['transactionId'] = params.transactionId; } if (params.locationId !== undefined) { allParams['locationId'] = params.locationId; } if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } } 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; } /** * List Subscriptions * The "List Subscriptions" API allows to retrieve a paginated list of subscriptions. Customize your results by filtering subscriptions based on name, alt type, subscription status, payment mode, date range, type of source, contact, subscription id, entity id, contact or paginate through the list using the provided query parameters. This endpoint provides a straightforward way to explore and retrieve subscription information. */ async listSubscriptions(params, options) { let url = '/payments/subscriptions'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.entityId !== undefined) { queryParams['entityId'] = params.entityId; } if (params.paymentMode !== undefined) { queryParams['paymentMode'] = params.paymentMode; } if (params.startAt !== undefined) { queryParams['startAt'] = params.startAt; } if (params.endAt !== undefined) { queryParams['endAt'] = params.endAt; } if (params.entitySourceType !== undefined) { queryParams['entitySourceType'] = params.entitySourceType; } if (params.search !== undefined) { queryParams['search'] = params.search; } if (params.contactId !== undefined) { queryParams['contactId'] = params.contactId; } if (params.id !== undefined) { queryParams['id'] = params.id; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.offset !== undefined) { queryParams['offset'] = params.offset; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.entityId !== undefined) { allParams['entityId'] = params.entityId; } if (params.paymentMode !== undefined) { allParams['paymentMode'] = params.paymentMode; } if (params.startAt !== undefined) { allParams['startAt'] = params.startAt; } if (params.endAt !== undefined) { allParams['endAt'] = params.endAt; } if (params.entitySourceType !== undefined) { allParams['entitySourceType'] = params.entitySourceType; } if (params.search !== undefined) { allParams['search'] = params.search; } if (params.contactId !== undefined) { allParams['contactId'] = params.contactId; } if (params.id !== undefined) { allParams['id'] = params.id; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.offset !== undefined) { allParams['offset'] = params.offset; } } 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 Subscription by ID * The "Get Subscription by ID" API allows to retrieve information for a specific subscription using its unique identifier. Use this endpoint to fetch details for a single subscription based on the provided subscription ID. */ async getSubscriptionById(params, options) { let url = '/payments/subscriptions/{subscriptionId}'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.subscriptionId !== undefined) { url = url.replace('{' + 'subscriptionId' + '}', encodeURIComponent(String(params.subscriptionId))); } if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.subscriptionId !== undefined) { allParams['subscriptionId'] = params.subscriptionId; } if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } } 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; } /** * List Coupons * The "List Coupons" API allows you to retrieve a list of all coupons available in your location. Use this endpoint to view all promotional offers and special discounts for your customers. */ async listCoupons(params, options) { let url = '/payments/coupon/list'; const queryParams = {}; const headerParams = {}; // Extract security requirements for this endpoint const securityRequirements = ["Location-Access"]; if (params) { if (params.altId !== undefined) { queryParams['altId'] = params.altId; } if (params.altType !== undefined) { queryParams['altType'] = params.altType; } if (params.limit !== undefined) { queryParams['limit'] = params.limit; } if (params.offset !== undefined) { queryParams['offset'] = params.offset; } if (params.status !== undefined) { queryParams['status'] = params.status; } if (params.search !== undefined) { queryParams['search'] = params.search; } } // Collect all parameters for token resolution (including path params) const allParams = {}; if (params) { if (params.altId !== undefined) { allParams['altId'] = params.altId; } if (params.altType !== undefined) { allParams['altType'] = params.altType; } if (params.limit !== undefined) { allParams['limit'] = params.limit; } if (params.offset !== undefined) { allParams['offset'] = params.offset; } if (params.status !== undefined) { allParams['status'] = params.status; } if (params.search !== undefined) { allParams['search'] = params.search; } } 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 Coupon * The "Create Coupon" API allows you to create a new promotional coupon with customizable parameters such as discount amount, validity period, usage limits, and applicable products. Use this endpoint to set up promotional offers and special discounts for your customers. */ async createCoupon(requestBody, options) { let url = '/payments/coupon'; 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; } /** * Update Coupon * The "Update Coupon" API enables you to mo