export type AddFiatPayoutDto = {provider: string, paymentProviderId: string}; export type AddStablecoinPayoutDto = {blockchainId: string, tokenId: string, spender: string}; export type AddNativePayoutDto = {blockchainId: string}; export type AddPayoutDto = {type: 'free' | 'fiat' | 'native' | 'stablecoin', name: string, fiatDetails?: AddFiatPayoutDto | undefined, stablecoinDetails?: AddStablecoinPayoutDto | undefined, nativeDetails?: AddNativePayoutDto | undefined}; export type CreateApiV1PayoutsAddArgs = {body: AddPayoutDto}; export type CreateApiV1PayoutsAddOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add payout * * POST /v1/payouts/add */ export const createApiV1PayoutsAdd = async (args: CreateApiV1PayoutsAddArgs, options: CreateApiV1PayoutsAddOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/payouts/add${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };