UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

69 lines (64 loc) • 2.79 kB
/** * Generated by orval v7.21.0 🍺 * Do not edit manually. * Coinbase Developer Platform APIs * The Coinbase Developer Platform APIs - leading the world's transition onchain. * OpenAPI spec version: 2.0.0 */ import type { CreateDisbursementRequest, Disbursement, DisbursementId, ListDisbursements200, ListDisbursementsParams, } from "../coinbaseDeveloperPlatformAPIs.schemas.js"; import { cdpApiClient } from "../../cdpApiClient.js"; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; /** * Creates a merchant-initiated payment of funds from a CDP account owned by the merchant to a Coinbase user account or onchain address. Used for standalone refunds, goodwill disbursements, rebates, and other merchant-driven payouts that are not tied to a specific payment session. This is an asynchronous operation. The disbursement is returned in `pending` status and transitions to `succeeded` (with associated `onchainTransactions`) or `failed` (with `error`). * @summary Create a disbursement */ export const createDisbursement = ( createDisbursementRequest: CreateDisbursementRequest, options?: SecondParameter<typeof cdpApiClient<Disbursement>>, ) => { return cdpApiClient<Disbursement>( { url: `/v2/disbursements`, method: "POST", headers: { "Content-Type": "application/json" }, data: createDisbursementRequest, }, options, ); }; /** * Returns a paginated list of disbursements created by the merchant. Each disbursement includes its source, target, status, amount, and timestamps. Only disbursements accessible by the current API key are returned. * @summary List disbursements */ export const listDisbursements = ( params?: ListDisbursementsParams, options?: SecondParameter<typeof cdpApiClient<ListDisbursements200>>, ) => { return cdpApiClient<ListDisbursements200>( { url: `/v2/disbursements`, method: "GET", params }, options, ); }; /** * Retrieves a single disbursement by its ID, including source, target, status, amount, associated onchain transactions, error details (if failed), and timestamps. Only returns the disbursement if the API key has permission to access it. * @summary Get a disbursement */ export const getDisbursement = ( disbursementId: DisbursementId, options?: SecondParameter<typeof cdpApiClient<Disbursement>>, ) => { return cdpApiClient<Disbursement>( { url: `/v2/disbursements/${disbursementId}`, method: "GET" }, options, ); }; export type CreateDisbursementResult = NonNullable<Awaited<ReturnType<typeof createDisbursement>>>; export type ListDisbursementsResult = NonNullable<Awaited<ReturnType<typeof listDisbursements>>>; export type GetDisbursementResult = NonNullable<Awaited<ReturnType<typeof getDisbursement>>>;