export type Channel = string; export type OrderCancellationRequestId = string; export type SellerId = string; export type ChannelOrderId = string; export type OrderItemId = unknown; export type CancelReason = 'BUYER_CANCELLED' | 'UNDELIVERABLE_TO_SHIPPING_ADDRESS' | 'UNDELIVERABLE_BY_CARRIER' | 'OUT_OF_STOCK' | 'DELAYED_INVENTORY' | 'PRICING_ERROR' | 'OTHER'; export type SellerOrderCancellationRequest = {channel: Channel, orderCancellationRequestId: OrderCancellationRequestId, sellerId: SellerId, orderId: ChannelOrderId, orderItem: Array<{orderItemId: OrderItemId, quantity?: string | undefined}> | null, cancelReason?: CancelReason | undefined, message?: string | undefined}; export type CreateApiV1ChannelOrderCancellationArgs = {body: SellerOrderCancellationRequest}; export type CreateApiV1ChannelOrderCancellationOptions = {baseUrl?: string | undefined, ChannelAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Request Order Cancellation * * POST /v1/channel/order/cancellation */ export const createApiV1ChannelOrderCancellation = async (args: CreateApiV1ChannelOrderCancellationArgs, options?: CreateApiV1ChannelOrderCancellationOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, ChannelAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ChannelAuth !== undefined) headers.set('authorization', `Bearer ${ChannelAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/channel/order/cancellation${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 };