export type BankAccount = {currency: string, data?: string | undefined, iban?: string | undefined, id?: string | undefined, name: string, type: 'iban' | 'custom'}; export type CreateApiBankAccountsArgs = {body: {bankAccount: BankAccount} | BankAccount}; export type CreateApiBankAccountsOptions = {baseUrl: string, ApiKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an invoice payment account * * POST /bank-accounts * * Also accepts auth: FirebaseIdToken */ export const createApiBankAccounts = async (args: CreateApiBankAccountsArgs, options: CreateApiBankAccountsOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyHeader !== undefined) headers.set("X-API-Key", ApiKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/bank-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 };