UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

120 lines • 4.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PaymentMethods = exports.BasePaymentMethods = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BasePaymentMethods = /* @__PURE__ */ (() => { class BasePaymentMethods extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/payment-methods`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/payment-methods/${paymentMethodID}/set-as-default`, options)._thenUnwrap((obj) => obj.result); } } BasePaymentMethods._key = Object.freeze([ 'accounts', 'paymentMethods', ]); return BasePaymentMethods; })(); exports.BasePaymentMethods = BasePaymentMethods; class PaymentMethods extends BasePaymentMethods { } exports.PaymentMethods = PaymentMethods; //# sourceMappingURL=payment-methods.js.map