UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

144 lines (131 loc) • 4.87 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 { CreateCustomerRequest, Customer, CustomerId, GetCustomerRequirementsParams, ListCustomers200, ListCustomersParams, RequirementsMap, UpdateCustomerRequest, } from "../coinbaseDeveloperPlatformAPIs.schemas.js"; import { cdpApiClient } from "../../cdpApiClient.js"; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; /** * Create a new customer record. You can optionally request capabilities and submit verification requirements in the same request. This endpoint supports creating a customer with: - Minimal data (customer type only) - Capability requests - KYC data submission - Combined request for capability and required info for verification * @summary Create a customer */ export const createCustomer = ( createCustomerRequest: CreateCustomerRequest, options?: SecondParameter<typeof cdpApiClient<Customer>>, ) => { return cdpApiClient<Customer>( { url: `/v2/customers`, method: "POST", headers: { "Content-Type": "application/json" }, data: createCustomerRequest, }, options, ); }; /** * List all customers. The API will return all customers that the API Key has permissions to access. Results are not returned in any guaranteed order. * @summary List customers */ export const listCustomers = ( params?: ListCustomersParams, options?: SecondParameter<typeof cdpApiClient<ListCustomers200>>, ) => { return cdpApiClient<ListCustomers200>({ url: `/v2/customers`, method: "GET", params }, options); }; /** * Preview the requirements a hypothetical customer of the given `customerType` and jurisdiction would need to satisfy to enable the requested `capabilities`, without creating a customer record. Partner onboarding UIs can use this to render the collection flow before any customer state exists. Today this endpoint only previews the Terms of Service requirement: the response's `RequirementsMap` will only ever contain a `tos` key. Other requirement families (PII / CDD inputs) are not yet available through this endpoint; use `POST /v2/customers` or `PUT /v2/customers/{customerId}` to discover those via `Customer.requirements`. Only `customerType: individual` customers resident in or citizens of the US are currently supported; every other combination returns `400 invalid_request`. * @summary Get customer requirements */ export const getCustomerRequirements = ( params: GetCustomerRequirementsParams, options?: SecondParameter<typeof cdpApiClient<RequirementsMap>>, ) => { return cdpApiClient<RequirementsMap>( { url: `/v2/customers/requirements`, method: "GET", params }, options, ); }; /** * Get a customer by their ID. Returns the full customer object. * @summary Get a customer */ export const getCustomerById = ( customerId: CustomerId, options?: SecondParameter<typeof cdpApiClient<Customer>>, ) => { return cdpApiClient<Customer>({ url: `/v2/customers/${customerId}`, method: "GET" }, options); }; /** * Initiates deletion of the customer and all associated data. This operation is idempotent — repeated calls for an already-deleted customer return 204. A 404 is returned only when no customer with the given ID exists for the caller's entity. * @summary Delete a customer */ export const deleteCustomerById = ( customerId: CustomerId, options?: SecondParameter<typeof cdpApiClient<void>>, ) => { return cdpApiClient<void>({ url: `/v2/customers/${customerId}`, method: "DELETE" }, options); }; /** * Update customer information and/or request capability changes. This endpoint supports partial updates. Provide only the fields you wish to change. * @summary Update a customer */ export const updateCustomerById = ( customerId: CustomerId, updateCustomerRequest: UpdateCustomerRequest, options?: SecondParameter<typeof cdpApiClient<Customer>>, ) => { return cdpApiClient<Customer>( { url: `/v2/customers/${customerId}`, method: "PUT", headers: { "Content-Type": "application/json" }, data: updateCustomerRequest, }, options, ); }; export type CreateCustomerResult = NonNullable<Awaited<ReturnType<typeof createCustomer>>>; export type ListCustomersResult = NonNullable<Awaited<ReturnType<typeof listCustomers>>>; export type GetCustomerRequirementsResult = NonNullable< Awaited<ReturnType<typeof getCustomerRequirements>> >; export type GetCustomerByIdResult = NonNullable<Awaited<ReturnType<typeof getCustomerById>>>; export type DeleteCustomerByIdResult = NonNullable<Awaited<ReturnType<typeof deleteCustomerById>>>; export type UpdateCustomerByIdResult = NonNullable<Awaited<ReturnType<typeof updateCustomerById>>>;