export type DispatchOptimizationInputSerializer = {orderIds?: (Array | null) | undefined, autoDispatch?: boolean | undefined}; export type CreateApiV1ActivitiesIdDispatchArgs = {id: string, body: DispatchOptimizationInputSerializer}; export type CreateApiV1ActivitiesIdDispatchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Dispatch Optimized Orders * * POST /v1/activities/{id}/dispatch */ export const createApiV1ActivitiesIdDispatch = async (args: CreateApiV1ActivitiesIdDispatchArgs, options?: CreateApiV1ActivitiesIdDispatchOptions) => { const {baseUrl = "https://api.sandbox.usenash.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/activities/${encodeURIComponent(String(args.id))}/dispatch${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 };