export type AddressRequest = {additional_info?: string | undefined, city: string, company?: string | undefined, country?: string | undefined, country_iso_code?: string | undefined, first_name?: string | undefined, last_name: string, phone?: string | undefined, state?: string | undefined, street?: string | undefined, street_additional_info?: string | undefined, zip_code?: string | undefined}; export type BillingInfoRequest = {address?: AddressRequest | undefined}; export type CustomAttributeRequest = {id: string, type: string}; export type CustomAttributesRequest = Array; export type FulfillmentRequest = {code?: string | undefined, type: string}; export type Money = {amount: number, currency: string}; export type TaxRequest = {amount: Money, channel_collectible?: Money | undefined, code: string, rate?: number | undefined, seller_collectible?: Money | undefined}; export type AdjustmentRequest = {channel_adjustment_id: string, created_at: string, price: Money, quantity: number, reason: string, shipping_price: Money, shipping_taxes?: Array | undefined, taxes?: Array | undefined, type: string}; export type ProductRequest = {id: string, thumbnail_url?: string | undefined, title: string}; export type OrderLineRequest = {adjustments?: Array | undefined, can_cancel: boolean, can_refund: boolean, channel_order_line_id: string, created_at: string, custom_attributes?: CustomAttributesRequest | undefined, price: Money, product: ProductRequest, quantity: number, ship_from?: ({warehouse?: ({id?: string | undefined}) | undefined}) | undefined, shipping_taxes?: Array | undefined, status: string, status_reason?: string | undefined, taxes?: Array | undefined, total_shipping_price: Money, updated_at: string}; export type ShippingInfoRequest = {address?: AddressRequest | undefined, carrier?: string | undefined, delivery_date?: {earliest: string, latest: string} | undefined, email?: string | undefined, method?: string | undefined, pudo_id?: string | undefined, shipping_deadline?: string | undefined}; export type OrderRequest = {billing_info?: BillingInfoRequest | undefined, channel_order_id: string, channel_updated_at: string, created_at: string, custom_attributes?: CustomAttributesRequest | undefined, fulfillment: FulfillmentRequest, has_incident?: boolean | undefined, order_lines: Array, shipping_info: ShippingInfoRequest, status: string, status_reason?: string | undefined, sub_channel_code?: string | undefined}; export type OriginRequest = {channel_id: string, channel_store_id: string}; export type UpsertOrdersRequest = {orders: Array, origin: OriginRequest}; export type CreateApiV1OrdersArgs = {body: UpsertOrdersRequest}; export type CreateApiV1OrdersOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * upsertOrders - Upsert orders * * POST /v1/orders */ export const createApiV1Orders = async (args: CreateApiV1OrdersArgs, options?: CreateApiV1OrdersOptions) => { const {baseUrl = "https://miraklconnect.com/api/channel-platform", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/orders${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 };