export type OcapiV1PersonName = {givenName?: (string | null) | undefined, familyName?: (string | null) | undefined, middleName?: (string | null) | undefined}; export type OcapiV1OrdersCustomersOrderCustomerPreferences = {languageTag?: (string | null) | undefined}; export type OcapiV1OrdersCustomersOrderCustomerTaxDetails = {name?: (string | null) | undefined, number?: (string | null) | undefined}; export type OcapiV1OrdersCustomersOrderCustomerAddress = {name?: OcapiV1PersonName | undefined, companyName?: (string | null) | undefined, phoneNumber?: (string | null) | undefined, line1?: (string | null) | undefined, suburb?: (string | null) | undefined, city?: (string | null) | undefined, state?: (string | null) | undefined, postCode?: (string | null) | undefined, country?: (string | null) | undefined}; export type OcapiV1OrdersCustomersRequestsOrderCustomerUpdate = {name?: OcapiV1PersonName | undefined, email: string, phoneNumber?: (string | null) | undefined, preferences?: OcapiV1OrdersCustomersOrderCustomerPreferences | undefined, taxDetails?: OcapiV1OrdersCustomersOrderCustomerTaxDetails | undefined, deliveryAddress?: OcapiV1OrdersCustomersOrderCustomerAddress | undefined, billingAddress?: OcapiV1OrdersCustomersOrderCustomerAddress | undefined}; export type UpdateApiOcapiV1OrdersOrderIdCustomerArgs = {orderId: string, 'Connect-Region-Code'?: string | undefined, body: OcapiV1OrdersCustomersRequestsOrderCustomerUpdate}; export type UpdateApiOcapiV1OrdersOrderIdCustomerOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Sets the customer for an in progress standard order, in progress gift shop order, * or in progress tab order * * PUT /ocapi/v1/orders/{orderId}/customer */ export const updateApiOcapiV1OrdersOrderIdCustomer = async (args: UpdateApiOcapiV1OrdersOrderIdCustomerArgs, options: UpdateApiOcapiV1OrdersOrderIdCustomerOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Connect-Region-Code'] != null) headers.set("Connect-Region-Code", String(args['Connect-Region-Code'])) const url = `${baseUrl.replace(/\/+$/, '')}/ocapi/v1/orders/${encodeURIComponent(String(args.orderId))}/customer${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };