export type CreateApiTrexityShipmentEventsArgs = {'X-Trexity-Signature': string, 'X-Trexity-Event-Name': string, body: string}; export type CreateApiTrexityShipmentEventsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /trexity/shipment-events */ export const createApiTrexityShipmentEvents = async (args: CreateApiTrexityShipmentEventsArgs, options: CreateApiTrexityShipmentEventsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Trexity-Signature'] != null) headers.set("X-Trexity-Signature", String(args['X-Trexity-Signature'])) if (args['X-Trexity-Event-Name'] != null) headers.set("X-Trexity-Event-Name", String(args['X-Trexity-Event-Name'])) const url = `${baseUrl.replace(/\/+$/, '')}/trexity/shipment-events${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 };