export type ShipmentAddress = {name?: string | undefined, company?: string | undefined, phone?: string | undefined, email?: string | undefined, zip?: string | undefined, city: string, state?: string | undefined, countryIso2?: string | undefined, street: string, street2?: string | undefined}; export type PickupsPostRequest = {sellerId: number, shippingServiceGroupId: number, parcelCount: number, pickupDate: string, pickupFrom?: ShipmentAddress | undefined}; export type CreateApiShipmentsPickupsArgs = {body: PickupsPostRequest}; export type CreateApiShipmentsPickupsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Book a pickup for booked shipments * * POST /shipments/pickups */ export const createApiShipmentsPickups = async (args: CreateApiShipmentsPickupsArgs, options?: CreateApiShipmentsPickupsOptions) => { const {baseUrl = "https://api.quivo.co", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/shipments/pickups${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 };