orb-billing
Version:
The official TypeScript library for the Orb API
76 lines • 3.38 kB
JavaScript
;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TopUps = void 0;
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
/**
* The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within Orb.
*/
class TopUps extends resource_1.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((0, path_1.path) `/customers/${customerID}/credits/top_ups`, { body, ...options });
}
/**
* List top-ups
*/
list(customerID, query = {}, options) {
return this._client.getAPIList((0, path_1.path) `/customers/${customerID}/credits/top_ups`, (pagination_1.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((0, path_1.path) `/customers/${customer_id}/credits/top_ups/${topUpID}`, {
...options,
headers: (0, headers_1.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((0, path_1.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((0, path_1.path) `/customers/external_customer_id/${external_customer_id}/credits/top_ups/${topUpID}`, { ...options, headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]) });
}
/**
* List top-ups by external ID
*/
listByExternalID(externalCustomerID, query = {}, options) {
return this._client.getAPIList((0, path_1.path) `/customers/external_customer_id/${externalCustomerID}/credits/top_ups`, (pagination_1.Page), { query, ...options });
}
}
exports.TopUps = TopUps;
//# sourceMappingURL=top-ups.js.map