import {z} from 'zod' export type LogisticsIdentifierType = 'AIR_WAYBILL' | 'BILL_OF_LADING' | 'HOUSE_BILL_OF_LADING' | 'BOOKING_NUMBER' | 'CARRIER_IATA' | 'CARRIER_ICAO' | 'CARRIER_NAME' | 'CARRIER_SCAC' | 'FFW_SCAC' | 'CONTAINER_ID' | 'CUSTOMER_REFERENCE' | 'DELIVERY_NUMBER' | 'EXTERNAL' | 'FLIGHT_NUMBER' | 'ORDER' | 'PICKUP' | 'PRO' | 'PURCHASE_ORDER' | 'RAIL_CAR_ID' | 'RAIL_WAYBILL' | 'TRACKING_NUMBER' | 'TRAILER_ID' | 'UNKNOWN' | 'VESSEL_IMO' | 'VESSEL_NAME' | 'WAYBILL' | 'VESSEL_CALL_SIGN' | 'VESSEL_MMSI' | 'CARRIER_US_DOT_NUMBER' | 'CARRIER_MC_NUMBER' | 'SUBSCRIPTION_ID' | 'HOUSE_AIR_WAYBILL' | 'SALES_ORDER' | 'WAREHOUSE_MOVEMENT_ORDER' | 'ADVANCED_SHIPMENT_NOTICE' | 'DRIVER_MOBILE_PHONE_NUMBER' | 'VEHICLE_ID' | 'LICENSE_PLATE' | 'SENSITECH_DEVICE_ID' | 'EMERSON_DEVICE_ID' | 'TIVE_DEVICE_ID' | 'VOYAGE_NUMBER' | 'CARRIER_MASTER_ID' | 'CARRIER_NMC_ID' | 'CONTAINER_TYPE' | 'TRAIN_NUMBER' | 'WAGON_ID' | 'CAPACITY_PROVIDER_ACCOUNT_GROUP' | 'CAPACITY_PROVIDER_ACCOUNT_CODE' | 'SERIAL_NUMBER' | 'VEHICLE_IDENTIFICATION_NUMBER' | 'REFERENCE_NUMBER' | 'CONTAINER_PIN' | 'INVOICE_ID' | 'VESSEL_P44_ID'; export type InternalEntityType = 'MASTER_SHIPMENT_ID' | 'BOOKING_ID' | 'STOP_ID' | 'DRIVER_ID' | 'TRUCKLOAD_TRACKING_ID' | 'ORDER_ID' | 'SHIPPER_TENANT_UUID'; export type Identifier = {type?: (LogisticsIdentifierType | InternalEntityType) | undefined, value?: string | undefined}; export type DocumentMode = 'AIR' | 'OCEAN' | 'TL' | 'LTL' | 'PARCEL' | 'RAIL' | 'BARGE'; export type DocumentType = 'BILL_OF_LADING' | 'HOUSE_BILL_OF_LADING' | 'AIRWAY_BILL' | 'COMMERCIAL_INVOICE' | 'CUSTOMS_DOCUMENTS' | 'PACKING_SLIP' | 'CERTIFICATE_OF_ORIGIN' | 'PROOF_OF_DELIVERY' | 'DELIVERY_RECEIPT' | 'ECMR' | 'WEIGHT_CERTIFICATE' | 'INSPECTION_CERTIFICATE' | 'LETTER_OF_AUTHORIZATION' | 'LUMPER_CERTIFICATE' | 'INVOICE' | 'HAZMAT_DOCUMENT' | 'SHIPPING_LABEL' | 'OTHER'; export type CreateUpdateDocument = {identifiers?: Array | undefined, mode?: DocumentMode | undefined, name?: string | undefined, type?: DocumentType | undefined}; export type UpdateApiServicesDocumentV1DocumentsDocumentIdArgs = {documentId: string, body: CreateUpdateDocument}; export type UpdateApiServicesDocumentV1DocumentsDocumentIdOptions = {baseUrl?: string | undefined, oAuth2?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiServicesDocumentV1DocumentsDocumentIdResponse = z.unknown(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Put Document * * PUT /services/document/v1/documents/{documentId} */ export const updateApiServicesDocumentV1DocumentsDocumentId = async (args: UpdateApiServicesDocumentV1DocumentsDocumentIdArgs, options?: UpdateApiServicesDocumentV1DocumentsDocumentIdOptions) => { const {baseUrl = "https://na12.api.project44.com", fetch: fetchFn = fetch, oAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (oAuth2 !== undefined) headers.set('authorization', `Bearer ${oAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/services/document/v1/documents/${encodeURIComponent(String(args.documentId))}${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 validateResponse(updateApiServicesDocumentV1DocumentsDocumentIdResponse, await res.json()) };