cloudflare
Version:
The official TypeScript library for the Cloudflare API
115 lines • 4.37 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BasePaymentMethods = /* @__PURE__ */ (() => {
class BasePaymentMethods extends APIResource {
/**
* Creates a new payment method for an account.
*
* @example
* ```ts
* const paymentMethod =
* await client.accounts.paymentMethods.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/payment-methods`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates a payment method for an account.
*
* @example
* ```ts
* const paymentMethod =
* await client.accounts.paymentMethods.update(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(paymentMethodID, params, options) {
const { account_id, ...body } = params;
return this._client.put(path `/accounts/${account_id}/payment-methods/${paymentMethodID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all payment methods for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const paymentMethodListResponse of client.accounts.paymentMethods.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/payment-methods`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a payment method from an account.
*
* @example
* ```ts
* const paymentMethod =
* await client.accounts.paymentMethods.delete(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(paymentMethodID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/payment-methods/${paymentMethodID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Gets a specific payment method for an account.
*
* @example
* ```ts
* const paymentMethod =
* await client.accounts.paymentMethods.get(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(paymentMethodID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/payment-methods/${paymentMethodID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Sets a payment method as the default for an account.
*
* @example
* ```ts
* const response =
* await client.accounts.paymentMethods.setAsDefault(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
setAsDefault(paymentMethodID, params, options) {
const { account_id } = params;
return this._client.post(path `/accounts/${account_id}/payment-methods/${paymentMethodID}/set-as-default`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePaymentMethods._key = Object.freeze([
'accounts',
'paymentMethods',
]);
return BasePaymentMethods;
})();
export class PaymentMethods extends BasePaymentMethods {
}
//# sourceMappingURL=payment-methods.mjs.map