cloudflare
Version:
The official TypeScript library for the Cloudflare API
99 lines • 3.61 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as SpendingLimitAPI from "./spending-limit.mjs";
import { BaseSpendingLimit, SpendingLimit, } from "./spending-limit.mjs";
import * as TopupAPI from "./topup/topup.mjs";
import { BaseTopup, Topup, } from "./topup/topup.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseBilling = /* @__PURE__ */ (() => {
class BaseBilling extends 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(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(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(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(path `/accounts/${account_id}/ai-gateway/billing/usage-history`, {
query,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseBilling._key = Object.freeze([
'aiGateway',
'billing',
]);
return BaseBilling;
})();
export 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;
Billing.BaseTopup = BaseTopup;
Billing.SpendingLimit = SpendingLimit;
Billing.BaseSpendingLimit = BaseSpendingLimit;
return Billing;
})();
//# sourceMappingURL=billing.mjs.map