diff --git a/src/coinbase/coinbase.ts b/src/coinbase/coinbase.ts index ea80bc43..6d3f28e9 100644 --- a/src/coinbase/coinbase.ts +++ b/src/coinbase/coinbase.ts @@ -1,6 +1,6 @@ import globalAxios from "axios"; import fs from "fs"; -import { UsersApiFactory, User as UserModel } from "../client"; +import { UsersApiFactory, TransfersApiFactory, User as UserModel } from "../client"; import { BASE_PATH } from "./../client/base"; import { Configuration } from "./../client/configuration"; import { CoinbaseAuthenticator } from "./authenticator"; @@ -45,6 +45,7 @@ export class Coinbase { ); axiosInstance.interceptors.response.use(response => logApiResponse(response, debugging)); 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 d5e0ad34..2c6e93b2 100644 --- a/src/coinbase/types.ts +++ b/src/coinbase/types.ts @@ -1,12 +1,18 @@ 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"; /** * UserAPI client type definition. */ 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 {Error} If the request fails. @@ -14,6 +20,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. @@ -24,4 +103,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.