Skip to content

Commit

Permalink
transfer api type
Browse files Browse the repository at this point in the history
  • Loading branch information
John-peterson-coinbase committed May 14, 2024
1 parent 3efbe1e commit 2007a99
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/coinbase/coinbase.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
}

/**
Expand Down
89 changes: 87 additions & 2 deletions src/coinbase/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,98 @@
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<UserModel>} - A promise resolving to the User model.
* @throws {Error} If the request fails.
*/
getCurrentUser(options?: AxiosRequestConfig): AxiosPromise<UserModel>;
};

/**
* 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<TransferModel>} - 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<TransferModel>;

/**
* 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<TransferModel>} - A promise resolving to the Transfer model.
* @throws {Error} If the request fails.
*/
createTransfer(
walletId: string,
addressId: string,
createTransferRequest: CreateTransferRequest,
options?: AxiosRequestConfig,
): AxiosPromise<TransferModel>;

/**
* 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<TransferModel>} - A promise resolving to the Transfer model.
* @throws {Error} If the request fails.
*/
getTransfer(
walletId: string,
addressId: string,
transferId: string,
options?: AxiosRequestConfig,
): AxiosPromise<TransferModel>;

/**
* 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<TransferList>} - 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<TransferList>;
};

/**
* API clients type definition for the Coinbase SDK.
* Represents the set of API clients available in the SDK.
Expand All @@ -24,4 +103,10 @@ export type ApiClients = {
* @type {UserAPIClient}
*/
user?: UserAPIClient;

/**
* The Transfer API client.
* @type {TransferAPIClient}
*/
transfer?: TransferAPIClient;
};
1 change: 1 addition & 0 deletions src/coinbase/user.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 2007a99

Please sign in to comment.