export type CustomerAddressDetailsRequest = {city: string, countryCode: string, firstName?: string | undefined, lastName?: string | undefined, lineOne: string, lineTwo?: string | undefined, postalCode: string, region: string}; export type CreateCustomerAddressRequest = {address: CustomerAddressDetailsRequest, type: 'BILLING' | 'SHIPPING' | 'RESIDENCE'}; export type CreateApiAccountsCustomersCustomerIdAddressesArgs = {customerId: string, body: CreateCustomerAddressRequest}; export type CreateApiAccountsCustomersCustomerIdAddressesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add an address to a customer * * POST /accounts/customers/{customerId}/addresses */ export const createApiAccountsCustomersCustomerIdAddresses = async (args: CreateApiAccountsCustomersCustomerIdAddressesArgs, options?: CreateApiAccountsCustomersCustomerIdAddressesOptions) => { 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/${encodeURIComponent(String(args.customerId))}/addresses${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() };