export type UpdateApiOrderArgs = {id?: number | undefined, body: {merchantId: number, totalAmount: string, balance: string, lineItems?: (Array<{id?: number | undefined, name?: string | undefined, price?: number | undefined, quantity?: string | undefined, discountAmount?: number | undefined, totalAmount?: number | undefined, taxCategory?: (Array<{id?: string | undefined, name?: string | undefined, code?: string | undefined, taxIds?: Array | undefined, totalTax?: string | undefined, isPrimary?: boolean | undefined, primaryExists?: boolean | undefined, display?: string | undefined, taxRate?: number | undefined}>) | undefined, initials?: string | undefined, taxes?: (Array<{id?: number | undefined, name?: string | undefined, description?: string | undefined, rate?: string | undefined, display?: string | undefined, taxCode?: string | undefined, taxCategoryId?: number | undefined}>) | undefined, amount?: string | undefined, taxAmount?: string | undefined, priceDiscountAmount?: string | undefined, taxRate?: number | undefined}>) | undefined, shippingLineItems?: (Array<{id?: number | undefined, name?: string | undefined, price?: number | undefined, quantity?: string | undefined, discountAmount?: number | undefined, totalAmount?: number | undefined, taxCategory?: (Array<{id?: string | undefined, name?: string | undefined, code?: string | undefined, taxIds?: Array | undefined, totalTax?: string | undefined, isPrimary?: boolean | undefined, primaryExists?: boolean | undefined, display?: string | undefined, taxRate?: number | undefined}>) | undefined, initials?: string | undefined, taxes?: (Array<{id?: number | undefined, name?: string | undefined, description?: string | undefined, rate?: string | undefined, display?: string | undefined, taxCode?: string | undefined, taxCategoryId?: number | undefined}>) | undefined, amount?: string | undefined, taxAmount?: string | undefined, priceDiscountAmount?: string | undefined, taxRate?: number | undefined}>) | undefined, orderStatus?: string | undefined, sourceType?: string | undefined, fulfillmentStatus?: string | undefined, paymentStatus?: string | undefined, orderedDate?: string | undefined, discounts?: (Array<{amount?: string | undefined, code?: string | undefined, collections?: Array | undefined, discountId?: number | undefined, discountRateType?: string | undefined, discountType?: string | undefined, merchantId?: number | undefined, name?: string | undefined, products?: Array | undefined, rate?: string | undefined}>) | undefined, taxAmount?: string | undefined, subtotalAmount?: string | undefined, customerName?: string | undefined, customer?: ({id?: number | undefined, name?: string | undefined, firstName?: string | undefined, lastName?: string | undefined, email?: string | undefined}) | undefined, customerId?: string | undefined, contactEmail?: string | undefined, notes?: string | undefined, shippedDate?: string | undefined, billingAddress?: ({address1?: string | undefined, address2?: string | undefined, isDefault?: boolean | undefined, state?: string | undefined, zip?: string | undefined}) | undefined, shippingAddress?: ({address1?: string | undefined, address2?: string | undefined, isDefault?: boolean | undefined, state?: string | undefined, zip?: string | undefined}) | undefined, lineItemCount?: number | undefined}}; export type UpdateApiOrderOptions = {baseUrl?: string | undefined, sec0?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Update Order * * PUT /order */ export const updateApiOrder = async (args: UpdateApiOrderArgs, options?: UpdateApiOrderOptions) => { const {baseUrl = "https://sandbox.api.mxmerchant.com/checkout", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.id != null) query.append("id", String(args.id)) if (sec0 !== undefined) headers.set('authorization', `Basic ${btoa(`${sec0.username}:${sec0.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/order${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 (await res.json()) as unknown };