export type OrderPutDeliveryAddress = {name?: string | undefined, company?: string | undefined, phone?: string | undefined, email?: string | undefined, street: string, street2?: string | undefined, zip?: string | undefined, city: string, state?: string | undefined, countryIso2: string, latitude?: number | undefined, longitude?: number | undefined}; export type UpdateApiOrdersOrderIdAddressArgs = {orderId: number, type?: ('DELIVERY' | 'INVOICE' | 'DELIVERY_AND_INVOICE') | undefined, body: OrderPutDeliveryAddress}; export type UpdateApiOrdersOrderIdAddressOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update the address of an order * * PUT /orders/{orderId}/address */ export const updateApiOrdersOrderIdAddress = async (args: UpdateApiOrdersOrderIdAddressArgs, options?: UpdateApiOrdersOrderIdAddressOptions) => { const {baseUrl = "https://api.quivo.co", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.type != null) query.append("type", String(args.type)) const url = `${baseUrl.replace(/\/+$/, '')}/orders/${encodeURIComponent(String(args.orderId))}/address${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 };