export type CustomerObject = {id?: string | undefined, name?: string | undefined, phone?: string | undefined, email?: string | undefined, address?: string | undefined, city?: string | undefined, postalCode?: string | undefined, country: string, locale?: string | undefined, createdAt?: string | undefined, updatedAt?: string | undefined}; export type CreateApiCustomersArgs = {createOrUpdate?: boolean | undefined, body: CustomerObject}; export type CreateApiCustomersOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new customer * * POST /customers */ export const createApiCustomers = async (args: CreateApiCustomersArgs, options?: CreateApiCustomersOptions) => { const {baseUrl = "https://api.test.bictorys.com/pay/v1", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.createOrUpdate != null) query.append("createOrUpdate", String(args.createOrUpdate)) if (ApiKeyAuth !== undefined) headers.set("X-API-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/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 undefined };