orb-billing
Version:
The official TypeScript library for the Orb API
58 lines • 2.71 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as LedgerAPI from "./ledger.mjs";
import { Ledger, } from "./ledger.mjs";
import * as TopUpsAPI from "./top-ups.mjs";
import { TopUps, } from "./top-ups.mjs";
import { Page } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
/**
* The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within Orb.
*/
export class Credits extends APIResource {
constructor() {
super(...arguments);
this.ledger = new LedgerAPI.Ledger(this._client);
this.topUps = new TopUpsAPI.TopUps(this._client);
}
/**
* Returns a paginated list of unexpired, non-zero credit blocks for a customer.
*
* If `include_all_blocks` is set to `true`, all credit blocks (including expired
* and depleted blocks) will be included in the response.
*
* Note that `currency` defaults to credits if not specified. To use a real world
* currency, set `currency` to an ISO 4217 string.
*
* Results can be filtered by the block's `effective_date` using the
* `effective_date[gte]`, `effective_date[gt]`, `effective_date[lt]`, and
* `effective_date[lte]` query parameters. This filters on when the credit block
* becomes effective, which may differ from creation time for backdated credits.
*/
list(customerID, query = {}, options) {
return this._client.getAPIList(path `/customers/${customerID}/credits`, (Page), {
query,
...options,
});
}
/**
* Returns a paginated list of unexpired, non-zero credit blocks for a customer.
*
* If `include_all_blocks` is set to `true`, all credit blocks (including expired
* and depleted blocks) will be included in the response.
*
* Note that `currency` defaults to credits if not specified. To use a real world
* currency, set `currency` to an ISO 4217 string.
*
* Results can be filtered by the block's `effective_date` using the
* `effective_date[gte]`, `effective_date[gt]`, `effective_date[lt]`, and
* `effective_date[lte]` query parameters. This filters on when the credit block
* becomes effective, which may differ from creation time for backdated credits.
*/
listByExternalID(externalCustomerID, query = {}, options) {
return this._client.getAPIList(path `/customers/external_customer_id/${externalCustomerID}/credits`, (Page), { query, ...options });
}
}
Credits.Ledger = Ledger;
Credits.TopUps = TopUps;
//# sourceMappingURL=credits.mjs.map