UNPKG

lago-javascript-client

Version:
1,424 lines 91.5 kB
"use strict"; /* eslint-disable */ /* tslint:disable */ /* * --------------------------------------------------------------- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## * ## ## * ## AUTHOR: acacode ## * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## * --------------------------------------------------------------- */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Api = exports.HttpClient = exports.ContentType = void 0; var ContentType; (function (ContentType) { ContentType["Json"] = "application/json"; ContentType["FormData"] = "multipart/form-data"; ContentType["UrlEncoded"] = "application/x-www-form-urlencoded"; ContentType["Text"] = "text/plain"; })(ContentType = exports.ContentType || (exports.ContentType = {})); class HttpClient { baseUrl = "https://api.getlago.com/api/v1"; securityData = null; securityWorker; abortControllers = new Map(); customFetch = (...fetchParams) => fetch(...fetchParams); baseApiParams = { credentials: "same-origin", headers: {}, redirect: "follow", referrerPolicy: "no-referrer", }; constructor(apiConfig = {}) { Object.assign(this, apiConfig); } setSecurityData = (data) => { this.securityData = data; }; encodeQueryParam(key, value) { const encodedKey = encodeURIComponent(key); return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; } addQueryParam(query, key) { return this.encodeQueryParam(key, query[key]); } addArrayQueryParam(query, key) { const value = query[key]; return value.map((v) => this.encodeQueryParam(key, v)).join("&"); } toQueryString(rawQuery) { const query = rawQuery || {}; const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); return keys .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) .join("&"); } addQueryParams(rawQuery) { const queryString = this.toQueryString(rawQuery); return queryString ? `?${queryString}` : ""; } contentFormatters = { [ContentType.Json]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, [ContentType.Text]: (input) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input), [ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => { const property = input[key]; formData.append(key, property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`); return formData; }, new FormData()), [ContentType.UrlEncoded]: (input) => this.toQueryString(input), }; mergeRequestParams(params1, params2) { return { ...this.baseApiParams, ...params1, ...(params2 || {}), headers: { ...(this.baseApiParams.headers || {}), ...(params1.headers || {}), ...((params2 && params2.headers) || {}), }, }; } createAbortSignal = (cancelToken) => { if (this.abortControllers.has(cancelToken)) { const abortController = this.abortControllers.get(cancelToken); if (abortController) { return abortController.signal; } return void 0; } const abortController = new AbortController(); this.abortControllers.set(cancelToken, abortController); return abortController.signal; }; abortRequest = (cancelToken) => { const abortController = this.abortControllers.get(cancelToken); if (abortController) { abortController.abort(); this.abortControllers.delete(cancelToken); } }; request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => { const secureParams = ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && (await this.securityWorker(this.securityData))) || {}; const requestParams = this.mergeRequestParams(params, secureParams); const queryString = query && this.toQueryString(query); const payloadFormatter = this.contentFormatters[type || ContentType.Json]; const responseFormat = format || requestParams.format; return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { ...requestParams, headers: { ...(requestParams.headers || {}), ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), }, signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null, body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), }).then(async (response) => { const r = response; r.data = null; r.error = null; const data = !responseFormat ? r : await response[responseFormat]() .then((data) => { if (r.ok) { r.data = data; } else { r.error = data; } return r; }) .catch((e) => { r.error = e; return r; }); if (cancelToken) { this.abortControllers.delete(cancelToken); } if (!response.ok) throw data; return data; }); }; } exports.HttpClient = HttpClient; /** * @title Lago API documentation * @version 1.36.0 * @license AGPLv3 * @baseUrl https://api.getlago.com/api/v1 * @externalDocs https://github.com/getlago * @contact <tech@getlago.com> * * Lago API allows your application to push customer information and metrics (events) from your application to the billing application. */ class Api extends HttpClient { billingEntities = { /** * @description This endpoint returns a list of all billing entities in the organization * * @tags billing_entities * @name ListBillingEntities * @summary List all billing entities * @request GET:/billing_entities * @secure */ listBillingEntities: (params = {}) => this.request({ path: `/billing_entities`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint is used to create a new billing entity * * @tags billing_entities * @name CreateBillingEntity * @summary Create a billing entity * @request POST:/billing_entities * @secure */ createBillingEntity: (data, params = {}) => this.request({ path: `/billing_entities`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint returns a specific billing entity by its code * * @tags billing_entities * @name GetBillingEntity * @summary Retrieve a billing entity * @request GET:/billing_entities/{code} * @secure */ getBillingEntity: (code, params = {}) => this.request({ path: `/billing_entities/${code}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint is used to update an existing billing entity * * @tags billing_entities * @name UpdateBillingEntity * @summary Update a billing entity * @request PUT:/billing_entities/{code} * @secure */ updateBillingEntity: (code, data, params = {}) => this.request({ path: `/billing_entities/${code}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), }; activityLogs = { /** * @description This endpoint retrieves all existing activity logs that represent actions performed on application resources. * * @tags activity_logs * @name FindAllActivityLogs * @summary List all activity logs * @request GET:/activity_logs * @secure */ findAllActivityLogs: (query, params = {}) => this.request({ path: `/activity_logs`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint retrieves an existing activity log that represents an action performed on some resource. The activity log is identified by its unique activity_id. * * @tags activity_logs * @name FindActivityLog * @summary Retrieve an activity log * @request GET:/activity_logs/{activity_id} * @secure */ findActivityLog: (activityId, params = {}) => this.request({ path: `/activity_logs/${activityId}`, method: "GET", secure: true, format: "json", ...params, }), }; addOns = { /** * @description This endpoint is used to create an add-on that can be then attached to a one-off invoice. * * @tags add_ons * @name CreateAddOn * @summary Create an add-on * @request POST:/add_ons * @secure */ createAddOn: (data, params = {}) => this.request({ path: `/add_ons`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used to list all existing add-ons. * * @tags add_ons * @name FindAllAddOns * @summary List all add-ons * @request GET:/add_ons * @secure */ findAllAddOns: (query, params = {}) => this.request({ path: `/add_ons`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to update an existing add-on. * * @tags add_ons * @name UpdateAddOn * @summary Update an add-on * @request PUT:/add_ons/{code} * @secure */ updateAddOn: (code, data, params = {}) => this.request({ path: `/add_ons/${code}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used to retrieve a specific add-on. * * @tags add_ons * @name FindAddOn * @summary Retrieve an add-on * @request GET:/add_ons/{code} * @secure */ findAddOn: (code, params = {}) => this.request({ path: `/add_ons/${code}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint is used to delete an existing add-on. * * @tags add_ons * @name DestroyAddOn * @summary Delete an add-on * @request DELETE:/add_ons/{code} * @secure */ destroyAddOn: (code, params = {}) => this.request({ path: `/add_ons/${code}`, method: "DELETE", secure: true, format: "json", ...params, }), }; apiLogs = { /** * @description This endpoint retrieves all existing api logs that represent requests performed to Lago's API. * * @tags api_logs * @name FindAllApiLogs * @summary List all api logs * @request GET:/api_logs * @secure */ findAllApiLogs: (query, params = {}) => this.request({ path: `/api_logs`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint retrieves an existing api log that represents a request made to the API. The api log is identified by its unique request_id. * * @tags api_logs * @name FindApiLog * @summary Retrieve an api log * @request GET:/api_logs/{request_id} * @secure */ findApiLog: (requestId, params = {}) => this.request({ path: `/api_logs/${requestId}`, method: "GET", secure: true, format: "json", ...params, }), }; analytics = { /** * @description Gross revenue is the sum of monthly `finalized` invoice payments and fees paid in advance that are not invoiceable. This total is calculated after deducting taxes and discounts. * * @tags analytics * @name FindAllGrossRevenues * @summary List gross revenue * @request GET:/analytics/gross_revenue * @secure */ findAllGrossRevenues: (query, params = {}) => this.request({ path: `/analytics/gross_revenue`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description Represents a monthly aggregation, detailing both the total count and the cumulative amount of invoices that have been marked as `finalized`. This report sorts invoices categorically based on their `payment_status`. * * @tags analytics * @name FindAllInvoiceCollections * @summary List of finalized invoices * @request GET:/analytics/invoice_collection * @secure */ findAllInvoiceCollections: (query, params = {}) => this.request({ path: `/analytics/invoice_collection`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description Reports a monthly analysis focused on the revenue generated from all usage-based fees. It exclusively accounts for revenue that has been formally invoiced. Importantly, this report does not include revenue related to the usage in the current billing period, limiting its scope to previously invoiced amounts. * * @tags analytics * @name FindAllInvoicedUsages * @summary List usage revenue * @request GET:/analytics/invoiced_usage * @secure */ findAllInvoicedUsages: (query, params = {}) => this.request({ path: `/analytics/invoiced_usage`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to list MRR. * * @tags analytics * @name FindAllMrrs * @summary List MRR * @request GET:/analytics/mrr * @secure */ findAllMrrs: (query, params = {}) => this.request({ path: `/analytics/mrr`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description Overdue balance is the total amount associated with overdue invoices (invoices with pending or failed payments which are past their due dates). * * @tags analytics * @name FindAllOverdueBalances * @summary List overdue balance * @request GET:/analytics/overdue_balance * @secure */ findAllOverdueBalances: (query, params = {}) => this.request({ path: `/analytics/overdue_balance`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description Returns usages. * * @tags analytics * @name FindAllUsages * @summary List usage * @request GET:/analytics/usage * @secure */ findAllUsages: (query, params = {}) => this.request({ path: `/analytics/usage`, method: "GET", query: query, secure: true, format: "json", ...params, }), }; appliedCoupons = { /** * @description This endpoint is used to apply a specific coupon to a customer, before or during a subscription. * * @tags coupons * @name ApplyCoupon * @summary Apply a coupon to a customer * @request POST:/applied_coupons * @secure */ applyCoupon: (data, params = {}) => this.request({ path: `/applied_coupons`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used to list all applied coupons. You can filter by coupon status and by customer. * * @tags coupons * @name FindAllAppliedCoupons * @summary List all applied coupons * @request GET:/applied_coupons * @secure */ findAllAppliedCoupons: (query, params = {}) => this.request({ path: `/applied_coupons`, method: "GET", query: query, secure: true, format: "json", ...params, }), }; billableMetrics = { /** * @description This endpoint creates a new billable metric representing a pricing component of your application. * * @tags billable_metrics * @name CreateBillableMetric * @summary Create a billable metric * @request POST:/billable_metrics * @secure */ createBillableMetric: (data, params = {}) => this.request({ path: `/billable_metrics`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint retrieves all existing billable metrics that represent pricing components of your application. * * @tags billable_metrics * @name FindAllBillableMetrics * @summary List all billable metrics * @request GET:/billable_metrics * @secure */ findAllBillableMetrics: (query, params = {}) => this.request({ path: `/billable_metrics`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description Evaluate an expression for a billable metric creation by providing the expression and test data * * @tags billable_metrics * @name EvaluateBillableMetricExpression * @summary Evaluate an expression for a billable metric * @request POST:/billable_metrics/evaluate_expression * @secure */ evaluateBillableMetricExpression: (data, params = {}) => this.request({ path: `/billable_metrics/evaluate_expression`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint updates an existing billable metric representing a pricing component of your application. * * @tags billable_metrics * @name UpdateBillableMetric * @summary Update a billable metric * @request PUT:/billable_metrics/{code} * @secure */ updateBillableMetric: (code, data, params = {}) => this.request({ path: `/billable_metrics/${code}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint deletes an existing billable metric representing a pricing component of your application. * * @tags billable_metrics * @name DestroyBillableMetric * @summary Delete a billable metric * @request DELETE:/billable_metrics/{code} * @secure */ destroyBillableMetric: (code, params = {}) => this.request({ path: `/billable_metrics/${code}`, method: "DELETE", secure: true, format: "json", ...params, }), /** * @description This endpoint retrieves an existing billable metric that represents a pricing component of your application. The billable metric is identified by its unique code. * * @tags billable_metrics * @name FindBillableMetric * @summary Retrieve a billable metric * @request GET:/billable_metrics/{code} * @secure */ findBillableMetric: (code, params = {}) => this.request({ path: `/billable_metrics/${code}`, method: "GET", secure: true, format: "json", ...params, }), }; features = { /** * @description This endpoint creates a new feature representing an entitlement component of your application. * * @tags features * @name CreateFeature * @summary Create a feature * @request POST:/features * @secure */ createFeature: (data, params = {}) => this.request({ path: `/features`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint retrieves all existing features that represent entitlement components of your application. * * @tags features * @name FindAllFeatures * @summary List all features * @request GET:/features * @secure */ findAllFeatures: (query, params = {}) => this.request({ path: `/features`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint updates an existing feature representing an entitlement component of your application. * * @tags features * @name UpdateFeature * @summary Update a feature * @request PUT:/features/{code} * @secure */ updateFeature: (code, data, params = {}) => this.request({ path: `/features/${code}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint deletes an existing feature representing an entitlement component of your application. Deleting a feature will remove it from all plans and subscriptions. * * @tags features * @name DestroyFeature * @summary Delete a feature * @request DELETE:/features/{code} * @secure */ destroyFeature: (code, params = {}) => this.request({ path: `/features/${code}`, method: "DELETE", secure: true, format: "json", ...params, }), /** * @description This endpoint retrieves an existing feature that represents an entitlement component of your application. The feature is identified by its unique code. * * @tags features * @name FindFeature * @summary Retrieve a feature * @request GET:/features/{code} * @secure */ findFeature: (code, params = {}) => this.request({ path: `/features/${code}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description Delete privilege from feature. Deleting a privilege removes it from all plans and subscriptions. * * @tags features * @name DeleteFeaturePrivilege * @summary Delete a privilege. Deleting a privilege removes it from all plans and subscriptions. * @request DELETE:/features/{code}/privileges/{privilege_code} * @secure */ deleteFeaturePrivilege: (code, privilegeCode, params = {}) => this.request({ path: `/features/${code}/privileges/${privilegeCode}`, method: "DELETE", secure: true, format: "json", ...params, }), }; coupons = { /** * @description This endpoint is used to create a coupon that can be then attached to a customer to create a discount. * * @tags coupons * @name CreateCoupon * @summary Create a coupon * @request POST:/coupons * @secure */ createCoupon: (data, params = {}) => this.request({ path: `/coupons`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used to list all existing coupons. * * @tags coupons * @name FindAllCoupons * @summary List all coupons * @request GET:/coupons * @secure */ findAllCoupons: (query, params = {}) => this.request({ path: `/coupons`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to update a coupon that can be then attached to a customer to create a discount. * * @tags coupons * @name UpdateCoupon * @summary Update a coupon * @request PUT:/coupons/{code} * @secure */ updateCoupon: (code, data, params = {}) => this.request({ path: `/coupons/${code}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used to retrieve a specific coupon. * * @tags coupons * @name FindCoupon * @summary Retrieve a coupon * @request GET:/coupons/{code} * @secure */ findCoupon: (code, params = {}) => this.request({ path: `/coupons/${code}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint is used to delete a coupon. * * @tags coupons * @name DestroyCoupon * @summary Delete a coupon * @request DELETE:/coupons/{code} * @secure */ destroyCoupon: (code, params = {}) => this.request({ path: `/coupons/${code}`, method: "DELETE", secure: true, format: "json", ...params, }), }; creditNotes = { /** * @description This endpoint creates a new credit note. * * @tags credit_notes * @name CreateCreditNote * @summary Create a credit note * @request POST:/credit_notes * @secure */ createCreditNote: (data, params = {}) => this.request({ path: `/credit_notes`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint list all existing credit notes. * * @tags credit_notes * @name FindAllCreditNotes * @summary List all credit notes * @request GET:/credit_notes * @secure */ findAllCreditNotes: (query, params = {}) => this.request({ path: `/credit_notes`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint updates an existing credit note. * * @tags credit_notes * @name UpdateCreditNote * @summary Update a credit note * @request PUT:/credit_notes/{lago_id} * @secure */ updateCreditNote: (lagoId, data, params = {}) => this.request({ path: `/credit_notes/${lagoId}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint retrieves an existing credit note. * * @tags credit_notes * @name FindCreditNote * @summary Retrieve a credit note * @request GET:/credit_notes/{lago_id} * @secure */ findCreditNote: (lagoId, params = {}) => this.request({ path: `/credit_notes/${lagoId}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint downloads the PDF of an existing credit note. * * @tags credit_notes * @name DownloadCreditNote * @summary Download a credit note PDF * @request POST:/credit_notes/{lago_id}/download * @secure */ downloadCreditNote: (lagoId, params = {}) => this.request({ path: `/credit_notes/${lagoId}/download`, method: "POST", secure: true, format: "json", ...params, }), /** * @description This endpoint allows you to retrieve amounts for a new credit note creation. * * @tags credit_notes * @name EstimateCreditNote * @summary Estimate amounts for a new credit note * @request POST:/credit_notes/estimate * @secure */ estimateCreditNote: (data, params = {}) => this.request({ path: `/credit_notes/estimate`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint voids the available credit linked to a specific credit note. * * @tags credit_notes * @name VoidCreditNote * @summary Void available credit * @request PUT:/credit_notes/{lago_id}/void * @secure */ voidCreditNote: (lagoId, params = {}) => this.request({ path: `/credit_notes/${lagoId}/void`, method: "PUT", secure: true, format: "json", ...params, }), }; customers = { /** * @description This endpoint creates a new customer. * * @tags customers * @name CreateCustomer * @summary Create a customer * @request POST:/customers * @secure */ createCustomer: (data, params = {}) => this.request({ path: `/customers`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint retrieves all existing customers. * * @tags customers * @name FindAllCustomers * @summary List all customers * @request GET:/customers * @secure */ findAllCustomers: (query, params = {}) => this.request({ path: `/customers`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint retrieves an existing customer. * * @tags customers * @name FindCustomer * @summary Retrieve a customer * @request GET:/customers/{external_customer_id} * @secure */ findCustomer: (externalCustomerId, params = {}) => this.request({ path: `/customers/${externalCustomerId}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint deletes an existing customer. * * @tags customers * @name DestroyCustomer * @summary Delete a customer * @request DELETE:/customers/{external_customer_id} * @secure */ destroyCustomer: (externalCustomerId, params = {}) => this.request({ path: `/customers/${externalCustomerId}`, method: "DELETE", secure: true, format: "json", ...params, }), /** * @description This endpoint is used to list all applied coupons for a customer. * * @tags customers, coupons * @name FindAllCustomerAppliedCoupons * @summary List all customer's applied coupons * @request GET:/customers/{external_customer_id}/applied_coupons * @secure */ findAllCustomerAppliedCoupons: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/applied_coupons`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to delete a specific coupon that has been applied to a customer. * * @tags coupons, customers * @name DeleteAppliedCoupon * @summary Delete an applied coupon * @request DELETE:/customers/{external_customer_id}/applied_coupons/{applied_coupon_id} * @secure */ deleteAppliedCoupon: (externalCustomerId, appliedCouponId, params = {}) => this.request({ path: `/customers/${externalCustomerId}/applied_coupons/${appliedCouponId}`, method: "DELETE", secure: true, format: "json", ...params, }), /** * @description This endpoint list all existing credit notes for a customer. * * @tags customers, credit_notes * @name FindAllCustomerCreditNotes * @summary List all customer's credit notes * @request GET:/customers/{external_customer_id}/credit_notes * @secure */ findAllCustomerCreditNotes: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/credit_notes`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used for retrieving all invoices of a customer. * * @tags customers, invoices * @name FindAllCustomerInvoices * @summary List all customer's invoices * @request GET:/customers/{external_customer_id}/invoices * @secure */ findAllCustomerInvoices: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/invoices`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to list all payments of a customer * * @tags customers, payments * @name FindAllCustomerPayments * @summary List all customer's payments * @request GET:/customers/{external_customer_id}/payments * @secure */ findAllCustomerPayments: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/payments`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to list all existing payment requests of a customer. * * @tags customers, payment_requests * @name FindAllCustomerPaymentRequests * @summary List all customer's payment requests * @request GET:/customers/{external_customer_id}/payment_requests * @secure */ findAllCustomerPaymentRequests: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/payment_requests`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description Retrieves an embeddable link for displaying a customer portal. This endpoint allows you to fetch the URL that can be embedded to provide customers access to a dedicated portal * * @tags customers * @name GetCustomerPortalUrl * @summary Get a customer portal URL * @request GET:/customers/{external_customer_id}/portal_url * @secure */ getCustomerPortalUrl: (externalCustomerId, params = {}) => this.request({ path: `/customers/${externalCustomerId}/portal_url`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint retrieves all active subscriptions for a customer. * * @tags customers, subscriptions * @name FindAllCustomerSubscriptions * @summary List all customer's subscriptions * @request GET:/customers/{external_customer_id}/subscriptions * @secure */ findAllCustomerSubscriptions: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/subscriptions`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used to list all wallets with prepaid credits of a customer * * @tags customers, wallets * @name FindAllCustomerWallets * @summary List all customer's wallets * @request GET:/customers/{external_customer_id}/wallets * @secure */ findAllCustomerWallets: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/wallets`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint enables the retrieval of the usage-based billing data for a customer within the current period. * * @tags customers * @name FindCustomerCurrentUsage * @summary Retrieve customer current usage * @request GET:/customers/{external_customer_id}/current_usage * @secure */ findCustomerCurrentUsage: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/current_usage`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint enables the retrieval of the usage-based billing data for a customer within the current period. It also returns the projected usage for the current period based on the current usage. * * @tags customers * @name FindCustomerProjectedUsage * @summary Retrieve customer current and projected usage * @request GET:/customers/{external_customer_id}/projected_usage * @secure */ findCustomerProjectedUsage: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/projected_usage`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint enables the retrieval of the usage-based billing data for a customer within past periods. * * @tags customers * @name FindAllCustomerPastUsage * @summary Retrieve customer past usage * @request GET:/customers/{external_customer_id}/past_usage * @secure */ findAllCustomerPastUsage: (externalCustomerId, query, params = {}) => this.request({ path: `/customers/${externalCustomerId}/past_usage`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint regenerates the Payment Provider Checkout URL of a Customer. * * @tags customers * @name GenerateCustomerCheckoutUrl * @summary Generate a Customer Payment Provider Checkout URL * @request POST:/customers/{external_customer_id}/checkout_url * @secure */ generateCustomerCheckoutUrl: (externalCustomerId, params = {}) => this.request({ path: `/customers/${externalCustomerId}/checkout_url`, method: "POST", secure: true, format: "json", ...params, }), }; events = { /** * @description This endpoint is used for transmitting usage measurement events to either a designated customer or a specific subscription. * * @tags events * @name CreateEvent * @summary Send usage events * @request POST:/events * @secure */ createEvent: (data, params = {}) => this.request({ path: `/events`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used for retrieving all events. * * @tags events * @name FindAllEvents * @summary List all events * @request GET:/events * @secure */ findAllEvents: (query, params = {}) => this.request({ path: `/events`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events. * * @tags events * @name CreateBatchEvents * @summary Batch multiple events * @request POST:/events/batch * @secure */ createBatchEvents: (data, params = {}) => this.request({ path: `/events/batch`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description Estimate the fees that would be created after reception of an event for a billable metric attached to one or multiple pay in advance charges * * @tags events * @name EventEstimateFees * @summary Estimate fees for a pay in advance charge * @request POST:/events/estimate_fees * @secure */ eventEstimateFees: (data, params = {}) => this.request({ path: `/events/estimate_fees`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description Estimate the fees that would be created after reception of an event for a billable metric attached to one or multiple pay in advance standard or percentage charges * * @tags events * @name EventEstimateInstantFees * @summary Estimate instant fees for a pay in advance charge * @request POST:/events/estimate_instant_fees * @secure */ eventEstimateInstantFees: (data, params = {}) => this.request({ path: `/events/estimate_instant_fees`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description Estimate the fees that would be created after reception of an event for a billable metric attached to one or multiple pay in advance standard or percentage charges * * @tags events * @name EventBatchEstimateInstantFees * @summary Batch estimate instant fees for a pay in advance charge * @request POST:/events/batch_estimate_instant_fees * @secure */ eventBatchEstimateInstantFees: (data, params = {}) => this.request({ path: `/events/batch_estimate_instant_fees`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used for retrieving a specific usage measurement event that has been sent to a customer or a subscription. * * @tags events * @name FindEvent * @summary Retrieve a specific event * @request GET:/events/{transaction_id} * @secure */ findEvent: (transactionId, params = {}) => this.request({ path: `/events/${transactionId}`, method: "GET", secure: true, format: "json", ...params, }), }; fees = { /** * @description This endpoint is used for retrieving all fees that has been issued. * * @tags fees * @name FindAllFees * @summary List all fees * @request GET:/fees * @secure */ findAllFees: (query, params = {}) => this.request({ path: `/fees`, method: "GET", query: query, secure: true, format: "json", ...params, }), /** * @description This endpoint is used for retrieving a specific fee that has been issued. * * @tags fees * @name FindFee * @summary Retrieve a specific fee * @request GET:/fees/{lago_id} * @secure */ findFee: (lagoId, params = {}) => this.request({ path: `/fees/${lagoId}`, method: "GET", secure: true, format: "json", ...params, }), /** * @description This endpoint is used for updating a specific fee that has been issued. * * @tags fees * @name UpdateFee * @summary Update a fee * @request PUT:/fees/{lago_id} * @secure */ updateFee: (lagoId, data, params = {}) => this.request({ path: `/fees/${lagoId}`, method: "PUT", body: data, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description This endpoint is used for deleting a specific fee that has not yet been invoiced * * @tags fees * @name DeleteFee * @summary Delete a fee * @request DELETE:/fees/{lago_id} * @secure */ deleteFee: (lagoId, params = {}) => this.request({ path: `/fees/${lagoId}`, method: "DELETE", secure: tr