UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

79 lines (67 loc) 3.34 kB
/** * @module Client */ // This file was auto-generated by Fern from our API Definition. import { AccountsClient } from "./api/resources/accounts/client/Client.js"; import { DepositDestinationsClient } from "./api/resources/depositDestinations/client/Client.js"; import { PaymentMethodsClient } from "./api/resources/paymentMethods/client/Client.js"; import { TransfersClient } from "./api/resources/transfers/client/Client.js"; import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js"; import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js"; import * as core from "./core/index.js"; export declare namespace CoinbaseApiClient { export type Options = BaseClientOptions; export interface RequestOptions extends BaseRequestOptions {} } export class CoinbaseApiClient { protected readonly _options: NormalizedClientOptionsWithAuth<CoinbaseApiClient.Options>; protected _accounts: AccountsClient | undefined; protected _depositDestinations: DepositDestinationsClient | undefined; protected _transfers: TransfersClient | undefined; protected _paymentMethods: PaymentMethodsClient | undefined; constructor(options: CoinbaseApiClient.Options) { this._options = normalizeClientOptionsWithAuth(options); } public get accounts(): AccountsClient { return (this._accounts ??= new AccountsClient(this._options)); } public get depositDestinations(): DepositDestinationsClient { return (this._depositDestinations ??= new DepositDestinationsClient(this._options)); } public get transfers(): TransfersClient { return (this._transfers ??= new TransfersClient(this._options)); } public get paymentMethods(): PaymentMethodsClient { return (this._paymentMethods ??= new PaymentMethodsClient(this._options)); } /** * Make a passthrough request using the SDK's configured auth, retry, logging, etc. * This is useful for making requests to endpoints not yet supported in the SDK. * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL. * * @param {Request | string | URL} input - The URL, path, or Request object. * @param {RequestInit} init - Standard fetch RequestInit options. * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal). * @returns {Promise<Response>} A standard Response object. */ public async fetch( input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions, ): Promise<Response> { return core.makePassthroughRequest( input, init, { baseUrl: this._options.baseUrl ?? this._options.environment, headers: this._options.headers, timeoutInSeconds: this._options.timeoutInSeconds, maxRetries: this._options.maxRetries, fetch: this._options.fetch, logging: this._options.logging, getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers, }, requestOptions, ); } }