From c83b649da5cff203c1d5678fc229fda9db62699b Mon Sep 17 00:00:00 2001 From: John Peterson Date: Tue, 14 May 2024 11:49:09 -0700 Subject: [PATCH] transfer api type --- src/coinbase/coinbase.ts | 3 +- src/coinbase/types.ts | 89 +++++++++++++++++++++++++++++++++++++++- src/coinbase/user.ts | 1 + 3 files changed, 90 insertions(+), 3 deletions(-) diff --git a/src/coinbase/coinbase.ts b/src/coinbase/coinbase.ts index 00268f59..7ab57de1 100644 --- a/src/coinbase/coinbase.ts +++ b/src/coinbase/coinbase.ts @@ -1,6 +1,6 @@ import globalAxios from "axios"; import fs from "fs"; -import { User as UserModel, UsersApiFactory } from "../client"; +import { User as UserModel, UsersApiFactory, TransfersApiFactory } from "../client"; import { BASE_PATH } from "./../client/base"; import { Configuration } from "./../client/configuration"; import { CoinbaseAuthenticator } from "./authenticator"; @@ -47,6 +47,7 @@ export class Coinbase { ); this.apiClients.user = UsersApiFactory(config, BASE_PATH, axiosInstance); + this.apiClients.transfer = TransfersApiFactory(config, BASE_PATH, axiosInstance); } /** diff --git a/src/coinbase/types.ts b/src/coinbase/types.ts index d0e175de..3f41b689 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -1,5 +1,11 @@ import { AxiosPromise, AxiosRequestConfig } from "axios"; -import { User as UserModel } from "./../client/api"; +import { + User as UserModel, + Transfer as TransferModel, + BroadcastTransferRequest, + CreateTransferRequest, + TransferList, +} from "./../client/api"; /** * AddressAPI client type definition. @@ -23,7 +29,7 @@ export type AddressAPIClient = { */ export type UserAPIClient = { /** - * Retrieves the current user. + * Retrieves the current User. * @param {AxiosRequestConfig} [options] - Axios request options. * @returns {AxiosPromise} - A promise resolving to the User model. * @throws {AxiosError} If the request fails. @@ -31,6 +37,79 @@ export type UserAPIClient = { getCurrentUser(options?: AxiosRequestConfig): AxiosPromise; }; +/** + * TransferAPI client type definition. + */ +export type TransferAPIClient = { + /** + * Broadcasts a transfer. + * @param {string} walletId - The ID of the wallet the address belongs to. + * @param {string} addressId - The ID of the address the transfer belongs to. + * @param {string} transferId - The ID of the transfer to broadcast. + * @param {BroadcastTransferRequest} broadcastTransferRequest - The request body. + * @param {AxiosRequestConfig} [options] - Axios request options. + * @returns {AxiosPromise} - A promise resolving to the Transfer model. + * @throws {Error} If the request fails. + */ + broadcastTransfer( + walletId: string, + addressId: string, + transferId: string, + broadcastTransferRequest: BroadcastTransferRequest, + options?: AxiosRequestConfig, + ): AxiosPromise; + + /** + * Creates a Transfer. + * @param {string} walletId - The ID of the wallet the address belongs to. + * @param {string} addressId - The ID of the address the transfer belongs to. + * @param {CreateTransferRequest} createTransferRequest - The request body. + * @param {AxiosRequestConfig} [options] - Axios request options. + * @returns {AxiosPromise} - A promise resolving to the Transfer model. + * @throws {Error} If the request fails. + */ + createTransfer( + walletId: string, + addressId: string, + createTransferRequest: CreateTransferRequest, + options?: AxiosRequestConfig, + ): AxiosPromise; + + /** + * Retrieves a Transfer. + * @param {string} walletId - The ID of the wallet the address belongs to. + * @param {string} addressId - The ID of the address the transfer belongs to. + * @param {string} transferId - The ID of the transfer to retrieve. + * @param {AxiosRequestConfig} [options] - Axios request options. + * @returns {AxiosPromise} - A promise resolving to the Transfer model. + * @throws {Error} If the request fails. + */ + getTransfer( + walletId: string, + addressId: string, + transferId: string, + options?: AxiosRequestConfig, + ): AxiosPromise; + + /** + * Lists Transfers. + * @param {string} walletId - The ID of the wallet the address belongs to. + * @param {string} addressId - The ID of the address the transfers belong to. + * @param {number} [limit] - The maximum number of transfers to return. + * @param {string} [page] - The cursor for pagination across multiple pages of Transfers. + * @param {AxiosRequestConfig} [options] - Axios request options. + * @returns {AxiosPromise} - A promise resolving to the Transfer list. + * @throws {Error} If the request fails. + */ + listTransfers( + walletId: string, + addressId: string, + limit?: number, + page?: string, + options?: AxiosRequestConfig, + ): AxiosPromise; +}; + /** * API clients type definition for the Coinbase SDK. * Represents the set of API clients available in the SDK. @@ -41,4 +120,10 @@ export type ApiClients = { * @type {UserAPIClient} */ user?: UserAPIClient; + + /** + * The Transfer API client. + * @type {TransferAPIClient} + */ + transfer?: TransferAPIClient; }; diff --git a/src/coinbase/user.ts b/src/coinbase/user.ts index 59d063f1..b7f144e4 100644 --- a/src/coinbase/user.ts +++ b/src/coinbase/user.ts @@ -1,5 +1,6 @@ import { ApiClients } from "./types"; import { User as UserModel } from "./../client/api"; + /** * A representation of a User. * Users have Wallets, which can hold balances of Assets.