UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

72 lines 3.12 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { Page } from "../../../core/pagination.mjs"; import { buildHeaders } from "../../../internal/headers.mjs"; import { path } from "../../../internal/utils/path.mjs"; /** * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within Orb. */ export class TopUps extends APIResource { /** * This endpoint allows you to create a new top-up for a specified customer's * balance. While this top-up is active, the customer's balance will added in * increments of the specified amount whenever the balance reaches the specified * threshold. * * If a top-up already exists for this customer in the same currency, the existing * top-up will be replaced. */ create(customerID, body, options) { return this._client.post(path `/customers/${customerID}/credits/top_ups`, { body, ...options }); } /** * List top-ups */ list(customerID, query = {}, options) { return this._client.getAPIList(path `/customers/${customerID}/credits/top_ups`, (Page), { query, ...options, }); } /** * This deactivates the top-up and voids any invoices associated with pending * credit blocks purchased through the top-up. */ delete(topUpID, params, options) { const { customer_id } = params; return this._client.delete(path `/customers/${customer_id}/credits/top_ups/${topUpID}`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * This endpoint allows you to create a new top-up for a specified customer's * balance. While this top-up is active, the customer's balance will added in * increments of the specified amount whenever the balance reaches the specified * threshold. * * If a top-up already exists for this customer in the same currency, the existing * top-up will be replaced. */ createByExternalID(externalCustomerID, body, options) { return this._client.post(path `/customers/external_customer_id/${externalCustomerID}/credits/top_ups`, { body, ...options, }); } /** * This deactivates the top-up and voids any invoices associated with pending * credit blocks purchased through the top-up. */ deleteByExternalID(topUpID, params, options) { const { external_customer_id } = params; return this._client.delete(path `/customers/external_customer_id/${external_customer_id}/credits/top_ups/${topUpID}`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]) }); } /** * List top-ups by external ID */ listByExternalID(externalCustomerID, query = {}, options) { return this._client.getAPIList(path `/customers/external_customer_id/${externalCustomerID}/credits/top_ups`, (Page), { query, ...options }); } } //# sourceMappingURL=top-ups.mjs.map