orb-billing
Version:
The official TypeScript library for the Orb API
65 lines • 2.92 kB
JavaScript
;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreditBlocks = void 0;
const resource_1 = require("../core/resource.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 CreditBlocks extends resource_1.APIResource {
/**
* This endpoint returns a credit block identified by its block_id.
*/
retrieve(blockID, options) {
return this._client.get((0, path_1.path) `/credit_blocks/${blockID}`, options);
}
/**
* This endpoint deletes a credit block by its ID.
*
* When a credit block is deleted:
*
* - The block is removed from the customer's credit ledger.
* - Any usage of the credit block is reversed, and the ledger is replayed as if
* the block never existed.
* - If invoices were generated from the purchase of the credit block, they will be
* deleted if in draft status, voided if issued, or a credit note will be issued
* if the invoice is paid.
*
* <Note>
* Issued invoices that had credits applied from this block will not be regenerated, but the ledger will
* reflect the state as if credits from the deleted block were never applied.
* </Note>
*/
delete(blockID, options) {
return this._client.delete((0, path_1.path) `/credit_blocks/${blockID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* This endpoint returns the credit block and its associated purchasing invoices.
*
* If a credit block was purchased (as opposed to being manually added), this
* endpoint returns the invoices that were created to charge the customer for the
* credit block. For credit blocks with payment schedules spanning multiple periods
* (e.g., monthly payments over 12 months), multiple invoices will be returned.
*
* For credit blocks created by subscription allocation prices, this endpoint
* returns the subscription invoice containing the allocation line item that
* created the block.
*
* If the credit block was not purchased (e.g., manual increment), an empty
* invoices list is returned.
*
* **Note: This endpoint is currently experimental and its interface may change in
* future releases. Please contact support before building production integrations
* against this endpoint.**
*/
listInvoices(blockID, options) {
return this._client.get((0, path_1.path) `/credit_blocks/${blockID}/invoices`, options);
}
}
exports.CreditBlocks = CreditBlocks;
//# sourceMappingURL=credit-blocks.js.map