export type CreateBeneficiaryRequest = {counterparty_id: number, cid: string, name: string, account_type: 'Bank' | 'Wallet', ccy?: string | undefined, host_name?: string | undefined, host_hub?: string | undefined, host_location?: string | undefined, host_country: string, node_name?: string | undefined, node_address?: string | undefined, node_location_line_1?: string | undefined, node_location_line_2?: string | undefined, node_location_line_3?: string | undefined, node_location_city?: string | undefined, node_location_region?: string | undefined, node_location_postcode?: string | undefined, node_country?: string | undefined, node_type: 'individual' | 'corporate', iban?: string | undefined, bic?: string | undefined, account_label?: string | undefined, payment_type?: string | undefined, email?: string | undefined, bcb_controlled: number, settlement_reference?: string | undefined, is_beneficiary: number}; export type CreateApiV4AccountsArgs = {body: CreateBeneficiaryRequest}; export type CreateApiV4AccountsOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Beneficiary * * POST /v4/accounts */ export const createApiV4Accounts = async (args: CreateApiV4AccountsArgs, options?: CreateApiV4AccountsOptions) => { const {baseUrl = "https://api.bcb.group", 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(/\/+$/, '')}/v4/accounts${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 };