|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../../core/resource'; |
| 4 | +import * as FiatAPI from '../../fiat'; |
| 5 | +import * as ActionsAPI from '../actions'; |
| 6 | +import { APIPromise } from '../../../core/api-promise'; |
| 7 | +import { buildHeaders } from '../../../internal/headers'; |
| 8 | +import { RequestOptions } from '../../../internal/request-options'; |
| 9 | +import { path } from '../../../internal/utils/path'; |
| 10 | + |
| 11 | +/** |
| 12 | + * Operations related to fiat onramping and offramping |
| 13 | + */ |
| 14 | +export class Fiat extends APIResource { |
| 15 | + /** |
| 16 | + * Initiates a payout (crypto to fiat offramp) from a wallet to a previously |
| 17 | + * registered external fiat account. Returns a pending wallet action; the crypto |
| 18 | + * transfer and fiat settlement are processed asynchronously. |
| 19 | + * |
| 20 | + * @example |
| 21 | + * ```ts |
| 22 | + * const payoutResponse = |
| 23 | + * await client.wallets.payout.fiat._create('wallet_id', { |
| 24 | + * destination: { fiat_account_id: 'fiat_account_id' }, |
| 25 | + * source: { |
| 26 | + * amount: 'amount', |
| 27 | + * asset: 'asset', |
| 28 | + * chain: 'chain', |
| 29 | + * }, |
| 30 | + * }); |
| 31 | + * ``` |
| 32 | + */ |
| 33 | + _create( |
| 34 | + walletID: string, |
| 35 | + params: FiatCreateParams, |
| 36 | + options?: RequestOptions, |
| 37 | + ): APIPromise<ActionsAPI.PayoutResponse> { |
| 38 | + const { |
| 39 | + 'privy-authorization-signature': privyAuthorizationSignature, |
| 40 | + 'privy-idempotency-key': privyIdempotencyKey, |
| 41 | + 'privy-request-expiry': privyRequestExpiry, |
| 42 | + ...body |
| 43 | + } = params; |
| 44 | + return this._client.post(path`/v1/wallets/${walletID}/payout/fiat`, { |
| 45 | + body, |
| 46 | + ...options, |
| 47 | + headers: buildHeaders([ |
| 48 | + { |
| 49 | + ...(privyAuthorizationSignature != null ? |
| 50 | + { 'privy-authorization-signature': privyAuthorizationSignature } |
| 51 | + : undefined), |
| 52 | + ...(privyIdempotencyKey != null ? { 'privy-idempotency-key': privyIdempotencyKey } : undefined), |
| 53 | + ...(privyRequestExpiry != null ? { 'privy-request-expiry': privyRequestExpiry } : undefined), |
| 54 | + }, |
| 55 | + options?.headers, |
| 56 | + ]), |
| 57 | + }); |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +export interface FiatCreateParams { |
| 62 | + /** |
| 63 | + * Body param: The destination bank account for a payout. |
| 64 | + */ |
| 65 | + destination: FiatAPI.PayoutDestination; |
| 66 | + |
| 67 | + /** |
| 68 | + * Body param: The source crypto asset, chain, and amount for a payout. |
| 69 | + */ |
| 70 | + source: FiatAPI.PayoutSource; |
| 71 | + |
| 72 | + /** |
| 73 | + * Header param: Request authorization signature. If multiple signatures are |
| 74 | + * required, they should be comma separated. |
| 75 | + */ |
| 76 | + 'privy-authorization-signature'?: string; |
| 77 | + |
| 78 | + /** |
| 79 | + * Header param: Idempotency keys ensure API requests are executed only once within |
| 80 | + * a 24-hour window. |
| 81 | + */ |
| 82 | + 'privy-idempotency-key'?: string; |
| 83 | + |
| 84 | + /** |
| 85 | + * Header param: Request expiry. Value is a Unix timestamp in milliseconds |
| 86 | + * representing the deadline by which the request must be processed. |
| 87 | + */ |
| 88 | + 'privy-request-expiry'?: string; |
| 89 | +} |
| 90 | + |
| 91 | +export declare namespace Fiat { |
| 92 | + export { type FiatCreateParams as FiatCreateParams }; |
| 93 | +} |
0 commit comments