export type DeliveryStatus = 'REQUESTED' | 'ALLOCATED' | 'PICKED_UP' | 'COMPLETED' | 'CANCELED' | 'ARRIVED_AT_PICKUP' | 'ARRIVED_AT_DROP_OFF'; export type PersonalIdentifiers = {taxIdentificationNumber?: (string | null) | undefined, serviceProviderId?: (string | null) | undefined} | null; export type Person = {name?: (string | null) | undefined, phone?: (string | null) | undefined, phoneCode?: (string | null) | undefined, email?: (string | null) | undefined, personalIdentifiers?: PersonalIdentifiers | undefined} | null; export type Location = {latitude: number, longitude: number} | null; export type VehicleInformation = {vehicleType?: ('WALKER' | 'MOTORCYCLE' | 'BICYCLE' | 'CAR' | 'VAN') | undefined, licensePlate?: (string | null) | undefined, makeModel?: (string | null) | undefined} | null; export type DeliveryCost = {baseCost?: number | undefined, extraCost?: number | undefined}; export type SignatureProof = {signatureImageUrl?: string | undefined, signerName?: (string | null) | undefined, signerRelationship?: (string | null) | undefined} | null; export type PictureProof = {pictureUrl?: string | undefined} | null; export type VerificationProof = {signatureProof?: SignatureProof | undefined, pictureProof?: PictureProof | undefined} | null; export type DropoffInfo = {courierNote?: (string | null) | undefined, proofOfDelivery?: VerificationProof | undefined} | null; export type DeliveryStatusUpdateRequest = {deliveryStatus?: DeliveryStatus | undefined, estimatedDeliveryTime?: (string | null) | undefined, estimatedPickupTime?: (string | null) | undefined, courier?: Person | undefined, location?: Location | undefined, createdAt?: string | undefined, vehicleInformation?: VehicleInformation | undefined, currencyCode?: (string | null) | undefined, cost?: DeliveryCost | undefined, providerDeliveryId?: (string | null) | undefined, dropoffInfo?: DropoffInfo | undefined, deliveryTrackingUrl?: (string | null) | undefined}; export type UpdateApiV1DeliveryDeliveryReferenceIdStatusArgs = {deliveryReferenceId: string, body: DeliveryStatusUpdateRequest}; export type UpdateApiV1DeliveryDeliveryReferenceIdStatusOptions = {baseUrl?: string | undefined, OAuth20?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update delivery status * * PUT /v1/delivery/{deliveryReferenceId}/status */ export const updateApiV1DeliveryDeliveryReferenceIdStatus = async (args: UpdateApiV1DeliveryDeliveryReferenceIdStatusArgs, options?: UpdateApiV1DeliveryDeliveryReferenceIdStatusOptions) => { const {baseUrl = "https://partners.tryotter.com", fetch: fetchFn = fetch, OAuth20} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth20 !== undefined) headers.set('authorization', `Bearer ${OAuth20}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/delivery/${encodeURIComponent(String(args.deliveryReferenceId))}/status${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };