UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

105 lines • 3.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Billing = exports.BaseBilling = void 0; const tslib_1 = require("../../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const SpendingLimitAPI = tslib_1.__importStar(require("./spending-limit.js")); const spending_limit_1 = require("./spending-limit.js"); const TopupAPI = tslib_1.__importStar(require("./topup/topup.js")); const topup_1 = require("./topup/topup.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseBilling = /* @__PURE__ */ (() => { class BaseBilling extends resource_1.APIResource { /** * Retrieve the current credit balance, payment method info, and top-up * configuration. * * @example * ```ts * const response = * await client.aiGateway.billing.creditBalance({ * account_id: 'account_id', * }); * ``` */ creditBalance(params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-gateway/billing/credit-balance`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieve a list of past invoices with pagination, optionally filtered by type. * * @example * ```ts * const response = * await client.aiGateway.billing.invoiceHistory({ * account_id: 'account_id', * }); * ``` */ invoiceHistory(params, options) { const { account_id, ...query } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-gateway/billing/invoice-history`, { query, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieve a preview of the upcoming invoice including line items and tax. * * @example * ```ts * const response = * await client.aiGateway.billing.invoicePreview({ * account_id: 'account_id', * }); * ``` */ invoicePreview(params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-gateway/billing/invoice-preview`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieve aggregated usage meter event summaries for the given time range. * * @example * ```ts * const response = * await client.aiGateway.billing.usageHistory({ * account_id: 'account_id', * value_grouping_window: 'day', * }); * ``` */ usageHistory(params, options) { const { account_id, ...query } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-gateway/billing/usage-history`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseBilling._key = Object.freeze([ 'aiGateway', 'billing', ]); return BaseBilling; })(); exports.BaseBilling = BaseBilling; var Billing = /* @__PURE__ */ (() => { class Billing extends BaseBilling { constructor() { super(...arguments); this.topup = new TopupAPI.Topup(this._client); this.spendingLimit = new SpendingLimitAPI.SpendingLimit(this._client); } } Billing.Topup = topup_1.Topup; Billing.BaseTopup = topup_1.BaseTopup; Billing.SpendingLimit = spending_limit_1.SpendingLimit; Billing.BaseSpendingLimit = spending_limit_1.BaseSpendingLimit; return Billing; })(); exports.Billing = Billing; //# sourceMappingURL=billing.js.map