orb-billing
Version:
The official TypeScript library for the Orb API
61 lines • 2.72 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../core/resource.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 CreditBlocks extends APIResource {
/**
* This endpoint returns a credit block identified by its block_id.
*/
retrieve(blockID, options) {
return this._client.get(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(path `/credit_blocks/${blockID}`, {
...options,
headers: 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(path `/credit_blocks/${blockID}/invoices`, options);
}
}
//# sourceMappingURL=credit-blocks.mjs.map