export type ReturnTrackingKeyShipmentsV1 = {carrier: 'DHL' | 'GLS' | 'HERMES', trackingNumber: string}; export type PositionItemShipmentsV1 = {positionItemId: string, salesOrderId: string, returnTrackingKey: ReturnTrackingKeyShipmentsV1, returnAddressCarrierId?: string | undefined}; export type CreateApiV1ShipmentsShipmentIdPositionitemsArgs = {shipmentId: string, body: Array}; export type CreateApiV1ShipmentsShipmentIdPositionitemsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Correct an existing shipment (add sent items) by shipment ID. * * POST /v1/shipments/{shipmentId}/positionitems */ export const createApiV1ShipmentsShipmentIdPositionitems = async (args: CreateApiV1ShipmentsShipmentIdPositionitemsArgs, options?: CreateApiV1ShipmentsShipmentIdPositionitemsOptions) => { const {baseUrl = "https://api.otto.market", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/shipments/${encodeURIComponent(String(args.shipmentId))}/positionitems${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 };