export type CustomerName = {firstName?: string | undefined, lastName?: string | undefined}; export type CreateCustomerRequest20230401 = {dateOfBirth?: string | undefined, email?: string | undefined, externalId?: string | undefined, name?: CustomerName | undefined, phone?: string | undefined, type?: ('INDIVIDUAL' | 'BUSINESS') | undefined}; export type CreateApiAccountsCustomersArgs = {body: CreateCustomerRequest20230401}; export type CreateApiAccountsCustomersOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new customer or retrieve a customer by its external id * * POST /accounts/customers */ export const createApiAccountsCustomers = async (args: CreateApiAccountsCustomersArgs, options?: CreateApiAccountsCustomersOptions) => { const {baseUrl = "https://api-sb.meld.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/accounts/customers${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 res.blob() };