export type UpsertAddressV3Dto = {line1: string, line2?: string | undefined, postalCode: string, city: string, state: string, country?: string | undefined, addressee?: string | undefined, isDefaultBilling: boolean, isDefaultShipping: boolean}; export type CreateApiV3CustomersIdAddressArgs = {id: string, body: UpsertAddressV3Dto}; export type CreateApiV3CustomersIdAddressOptions = {baseUrl?: string | undefined, customHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create customer address * * POST /v3/customers/{id}/address */ export const createApiV3CustomersIdAddress = async (args: CreateApiV3CustomersIdAddressArgs, options?: CreateApiV3CustomersIdAddressOptions) => { const {baseUrl = "https://integrators.prod.api.tabsplatform.com", fetch: fetchFn = fetch, customHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (customHeader !== undefined) headers.set("Authorization", customHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v3/customers/${encodeURIComponent(String(args.id))}/address${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 };