import {z} from 'zod' export type AssociatedRecord = {reference?: string | undefined, creationDate?: string | undefined, originSystemCode?: string | undefined, flightOfferId?: string | undefined}; export type FlightOfferSource = 'GDS'; export type TravelClass = 'ECONOMY' | 'PREMIUM_ECONOMY' | 'BUSINESS' | 'FIRST'; export type Co2Emission = {weight?: number | undefined, weightUnit?: string | undefined, cabin?: TravelClass | undefined}; export type FlightEndPoint = {iataCode?: string | undefined, terminal?: string | undefined, at?: string | undefined}; export type AircraftEquipment = {code?: string | undefined}; export type OperatingFlight = {carrierCode?: string | undefined}; export type FlightStop = {iataCode?: string | undefined, duration?: string | undefined, arrivalAt?: string | undefined, departureAt?: string | undefined}; export type Segment = {id?: string | undefined, numberOfStops?: number | undefined, blacklistedInEU?: boolean | undefined, co2Emissions?: Array | undefined, departure?: FlightEndPoint | undefined, arrival?: FlightEndPoint | undefined, carrierCode?: string | undefined, number?: string | undefined, aircraft?: AircraftEquipment | undefined, operating?: OperatingFlight | undefined, duration?: string | undefined, stops?: Array | undefined}; export type AdditionalServiceType = 'CHECKED_BAGS' | 'MEALS' | 'SEATS' | 'OTHER_SERVICES'; export type FeeType = 'TICKETING' | 'FORM_OF_PAYMENT' | 'SUPPLIER'; export type Fee = {amount?: string | undefined, type?: FeeType | undefined}; export type Tax = {amount?: string | undefined, code?: string | undefined}; export type ExtendedPrice = {margin?: string | undefined, grandTotal?: string | undefined, billingCurrency?: string | undefined, additionalServices?: (Array<{amount?: string | undefined, type?: AdditionalServiceType | undefined}>) | undefined, currency?: string | undefined, total?: string | undefined, base?: string | undefined, fees?: Array | undefined, taxes?: Array | undefined, refundableTaxes?: string | undefined}; export type PricingOptionsFareType = Array<'PUBLISHED'>; export type TravelerPricingFareOption = 'STANDARD' | 'INCLUSIVE_TOUR' | 'SPANISH_MELILLA_RESIDENT' | 'SPANISH_CEUTA_RESIDENT' | 'SPANISH_CANARY_RESIDENT' | 'SPANISH_BALEARIC_RESIDENT' | 'AIR_FRANCE_METROPOLITAN_DISCOUNT_PASS' | 'AIR_FRANCE_DOM_DISCOUNT_PASS' | 'AIR_FRANCE_COMBINED_DISCOUNT_PASS' | 'AIR_FRANCE_FAMILY' | 'ADULT_WITH_COMPANION' | 'COMPANION'; export type TravelerType = 'ADULT' | 'CHILD' | 'SENIOR' | 'YOUNG' | 'HELD_INFANT' | 'SEATED_INFANT' | 'STUDENT'; export type Price = {currency?: string | undefined, total?: string | undefined, base?: string | undefined, fees?: Array | undefined, taxes?: Array | undefined, refundableTaxes?: string | undefined}; export type AllotmentDetails = {tourName?: string | undefined, tourReference?: string | undefined}; export type SliceDiceIndicator = 'LOCAL_AVAILABILITY' | 'SUB_OD_AVAILABILITY_1' | 'SUB_OD_AVAILABILITY_2'; export type BaggageAllowance = {quantity?: number | undefined, weight?: number | undefined, weightUnit?: string | undefined}; export type ChargeableCheckdBags = {quantity?: number | undefined, weight?: number | undefined, weightUnit?: string | undefined, id?: string | undefined}; export type ChargeableSeat = {id?: string | undefined, number?: string | undefined}; export type ServiceName = 'PRIORITY_BOARDING' | 'AIRPORT_CHECKIN'; export type FlightOffer = {type: string, id: string, source?: FlightOfferSource | undefined, instantTicketingRequired?: boolean | undefined, disablePricing?: boolean | undefined, nonHomogeneous?: boolean | undefined, oneWay?: boolean | undefined, paymentCardRequired?: boolean | undefined, lastTicketingDate?: string | undefined, lastTicketingDateTime?: string | undefined, numberOfBookableSeats?: number | undefined, itineraries?: (Array<{duration?: string | undefined, segments: Array}>) | undefined, price?: ExtendedPrice | undefined, pricingOptions?: ({fareType?: PricingOptionsFareType | undefined, includedCheckedBagsOnly?: boolean | undefined, refundableFare?: boolean | undefined, noRestrictionFare?: boolean | undefined, noPenaltyFare?: boolean | undefined}) | undefined, validatingAirlineCodes?: Array | undefined, travelerPricings?: (Array<{travelerId: string, fareOption: TravelerPricingFareOption, travelerType: TravelerType, associatedAdultId?: string | undefined, price?: Price | undefined, fareDetailsBySegment: Array<{segmentId: string, cabin?: TravelClass | undefined, fareBasis?: string | undefined, brandedFare?: string | undefined, class?: string | undefined, isAllotment?: boolean | undefined, allotmentDetails?: AllotmentDetails | undefined, sliceDiceIndicator?: SliceDiceIndicator | undefined, includedCheckedBags?: BaggageAllowance | undefined, additionalServices?: ({chargeableCheckedBags?: ChargeableCheckdBags | undefined, chargeableSeat?: ChargeableSeat | undefined, chargeableSeatNumber?: string | undefined, otherServices?: Array | undefined}) | undefined}>}>) | undefined}; export type StakeholderGender = 'MALE' | 'FEMALE' | 'UNSPECIFIED' | 'UNDISCLOSED'; export type Name = {firstName?: string | undefined, lastName?: string | undefined, middleName?: string | undefined, secondLastName?: string | undefined}; export type DocumentType = 'VISA' | 'PASSPORT' | 'IDENTITY_CARD' | 'KNOWN_TRAVELER' | 'REDRESS'; export type IdentityDocument = {number?: string | undefined, issuanceDate?: string | undefined, expiryDate?: string | undefined, issuanceCountry?: string | undefined, issuanceLocation?: string | undefined, nationality?: string | undefined, birthPlace?: string | undefined, documentType?: DocumentType | undefined, validityCountry?: string | undefined, birthCountry?: string | undefined, holder?: boolean | undefined}; export type EmergencyContact = {addresseeName?: string | undefined, countryCode?: string | undefined, number?: string | undefined, text?: string | undefined}; export type LoyaltyProgram = {programOwner?: string | undefined, id?: string | undefined}; export type DiscountType = 'SPANISH_RESIDENT' | 'AIR_FRANCE_DOMESTIC' | 'AIR_FRANCE_COMBINED' | 'AIR_FRANCE_METROPOLITAN'; export type DiscountTravelerType = 'SPANISH_CITIZEN' | 'EUROPEAN_CITIZEN' | 'GOVERNMENT_WORKER' | 'MILITARY' | 'MINOR_WITHOUT_ID'; export type Discount = {subType?: DiscountType | undefined, cityName?: string | undefined, travelerType?: DiscountTravelerType | undefined, cardNumber?: string | undefined, certificateNumber?: string | undefined}; export type Address = {lines?: Array | undefined, postalCode?: string | undefined, countryCode?: string | undefined, cityName?: string | undefined, stateName?: string | undefined, postalBox?: string | undefined}; export type ContactPurpose = 'STANDARD' | 'INVOICE' | 'STANDARD_WITHOUT_TRANSMISSION'; export type PhoneDeviceType = 'MOBILE' | 'LANDLINE' | 'FAX'; export type Phone = {deviceType?: PhoneDeviceType | undefined, countryCallingCode?: string | undefined, number?: string | undefined}; export type Contact = {addresseeName?: Name | undefined, address?: Address | undefined, language?: string | undefined, purpose?: ContactPurpose | undefined, phones?: Array | undefined, companyName?: string | undefined, emailAddress?: string | undefined}; export type Traveler = {id?: string | undefined, dateOfBirth?: string | undefined, gender?: StakeholderGender | undefined, name?: Name | undefined, documents?: Array | undefined, emergencyContact?: EmergencyContact | undefined, loyaltyPrograms?: Array | undefined, discountEligibility?: Array | undefined, contact?: Contact | undefined}; export type GeneralRemarkType = 'GENERAL_MISCELLANEOUS' | 'CONFIDENTIAL' | 'INVOICE' | 'QUALITY_CONTROL' | 'BACKOFFICE' | 'FULFILLMENT' | 'ITINERARY' | 'TICKETING_MISCELLANEOUS' | 'TOUR_CODE'; export type GeneralRemark = {subType: GeneralRemarkType, category?: string | undefined, text: string, travelerIds?: Array | undefined, flightOfferIds?: Array | undefined}; export type AirlineRemarkType = 'OTHER_SERVICE_INFORMATION' | 'KEYWORD' | 'OTHER_SERVICE' | 'CLIENT_ID' | 'ADVANCED_TICKET_TIME_LIMIT'; export type AirlineRemark = {subType: AirlineRemarkType, keyword?: string | undefined, airlineCode: string, text: string, travelerIds?: Array | undefined, flightOfferIds?: Array | undefined}; export type Remarks = {general?: Array | undefined, airline?: Array | undefined}; export type CreditCardBrand = 'VISA' | 'AMERICAN_EXPRESS' | 'MASTERCARD' | 'VISA_ELECTRON' | 'VISA_DEBIT' | 'MASTERCARD_DEBIT' | 'MAESTRO' | 'DINERS' | 'EASYPAY'; export type VirtualCreditCardDetails = {brand?: CreditCardBrand | undefined, holder?: string | undefined, number?: string | undefined, expiryDate?: string | undefined, amount?: string | undefined, currencyCode?: string | undefined}; export type B2bWallet = {cardId?: string | undefined, cardUsageName?: string | undefined, cardFriendlyName?: string | undefined, reportingData?: (Array<{name?: string | undefined, value?: string | undefined}>) | undefined, virtualCreditCardDetails?: VirtualCreditCardDetails | undefined, flightOfferIds?: Array | undefined}; export type CreditCard = {brand?: CreditCardBrand | undefined, holder?: string | undefined, number?: string | undefined, expiryDate?: string | undefined, securityCode?: string | undefined, flightOfferIds?: Array | undefined}; export type OtherPaymentMethod = 'ACCOUNT' | 'CHECK' | 'CASH' | 'NONREFUNDABLE'; export type OtherMethod = {method?: OtherPaymentMethod | undefined, flightOfferIds?: Array | undefined}; export type FormOfPayment = {b2bWallet?: B2bWallet | undefined, creditCard?: CreditCard | undefined, other?: OtherMethod | undefined}; export type TicketingAgreementOption = 'CONFIRM' | 'DELAY_TO_QUEUE' | 'DELAY_TO_CANCEL'; export type TicketingAgreement = {option?: TicketingAgreementOption | undefined, delay?: string | undefined, dateTime?: string | undefined, segmentIds?: Array | undefined}; export type AutomatedProcessCode = 'IMMEDIATE' | 'DELAYED' | 'ERROR'; export type AutomatedProcess = {code?: AutomatedProcessCode | undefined, queue?: ({number?: string | undefined, category?: string | undefined}) | undefined, text?: string | undefined, delay?: string | undefined, officeId?: string | undefined, dateTime?: string | undefined}; export type AirTravelDocument = {documentType?: ('ETICKET' | 'PTICKET' | 'EMD' | 'MCO') | undefined, documentNumber?: string | undefined, documentStatus?: ('ISSUED' | 'REFUNDED' | 'VOID' | 'ORIGINAL' | 'EXCHANGED') | undefined, travelerId?: string | undefined, segmentIds?: Array | undefined}; export type FormOfIdentification = {identificationType?: ('DRIVERS_LICENSE' | 'PASSPORT' | 'NATIONAL_IDENTITY_CARD' | 'BOOKING_CONFIRMATION' | 'TICKET' | 'OTHER_ID') | undefined, carrierCode?: string | undefined, number?: string | undefined, travelerIds?: Array | undefined, flightOfferIds?: Array | undefined}; export type FlightOrder = {type: string, id?: string | undefined, queuingOfficeId?: string | undefined, ownerOfficeId?: string | undefined, associatedRecords?: Array | undefined, flightOffers: Array, travelers?: Array | undefined, remarks?: Remarks | undefined, formOfPayments?: Array | undefined, ticketingAgreement?: TicketingAgreement | undefined, automatedProcess?: Array | undefined, contacts?: Array | undefined, tickets?: Array | undefined, formOfIdentifications?: Array | undefined}; export type CreateApiBookingFlightOrdersArgs = {body: {data?: FlightOrder | undefined}}; export type CreateApiBookingFlightOrdersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const collectionMetaLink = z.object({count: z.number().int().optional(), links: z.object({self: z.string().optional(), next: z.string().optional(), previous: z.string().optional(), last: z.string().optional(), first: z.string().optional(), up: z.string().optional()}).optional()}); export const issue = z.object({status: z.number().int().optional(), code: z.number().int().optional(), title: z.string().optional(), detail: z.string().optional(), source: z.object({pointer: z.string().optional(), parameter: z.string().optional(), example: z.string().optional()}).optional()}); export const associatedRecord = z.object({reference: z.string().optional(), creationDate: z.string().optional(), originSystemCode: z.string().min(2).max(3).optional(), flightOfferId: z.string().optional()}); export const flightOfferSource = z.literal("GDS"); export const travelClass = z.enum(["ECONOMY", "PREMIUM_ECONOMY", "BUSINESS", "FIRST"]); export const co2Emission = z.object({weight: z.number().int().optional(), weightUnit: z.string().optional(), cabin: travelClass.optional()}); export const flightEndPoint = z.object({iataCode: z.string().optional(), terminal: z.string().optional(), at: z.string().optional()}); export const aircraftEquipment = z.object({code: z.string().optional()}); export const operatingFlight = z.object({carrierCode: z.string().min(1).max(2).optional()}); export const flightStop = z.object({iataCode: z.string().optional(), duration: z.string().optional(), arrivalAt: z.string().optional(), departureAt: z.string().optional()}); export const segment = z.object({id: z.string().optional(), numberOfStops: z.number().int().optional(), blacklistedInEU: z.boolean().optional(), co2Emissions: z.array(co2Emission).optional(), departure: flightEndPoint.optional(), arrival: flightEndPoint.optional(), carrierCode: z.string().min(1).max(2).optional(), number: z.string().min(1).max(4).optional(), aircraft: aircraftEquipment.optional(), operating: operatingFlight.optional(), duration: z.string().optional(), stops: z.array(flightStop).optional()}); export const additionalServiceType = z.enum(["CHECKED_BAGS", "MEALS", "SEATS", "OTHER_SERVICES"]); export const feeType = z.enum(["TICKETING", "FORM_OF_PAYMENT", "SUPPLIER"]); export const fee = z.object({amount: z.string().optional(), type: feeType.optional()}); export const tax = z.object({amount: z.string().optional(), code: z.string().optional()}); export const extendedPrice = z.object({margin: z.string().optional(), grandTotal: z.string().optional(), billingCurrency: z.string().optional(), additionalServices: z.array(z.object({amount: z.string().optional(), type: additionalServiceType.optional()})).optional(), currency: z.string().optional(), total: z.string().optional(), base: z.string().optional(), fees: z.array(fee).optional(), taxes: z.array(tax).optional(), refundableTaxes: z.string().optional()}); export const pricingOptionsFareType = z.array(z.literal("PUBLISHED")); export const travelerPricingFareOption = z.enum(["STANDARD", "INCLUSIVE_TOUR", "SPANISH_MELILLA_RESIDENT", "SPANISH_CEUTA_RESIDENT", "SPANISH_CANARY_RESIDENT", "SPANISH_BALEARIC_RESIDENT", "AIR_FRANCE_METROPOLITAN_DISCOUNT_PASS", "AIR_FRANCE_DOM_DISCOUNT_PASS", "AIR_FRANCE_COMBINED_DISCOUNT_PASS", "AIR_FRANCE_FAMILY", "ADULT_WITH_COMPANION", "COMPANION"]); export const travelerType = z.enum(["ADULT", "CHILD", "SENIOR", "YOUNG", "HELD_INFANT", "SEATED_INFANT", "STUDENT"]); export const price = z.object({currency: z.string().optional(), total: z.string().optional(), base: z.string().optional(), fees: z.array(fee).optional(), taxes: z.array(tax).optional(), refundableTaxes: z.string().optional()}); export const allotmentDetails = z.object({tourName: z.string().optional(), tourReference: z.string().optional()}); export const sliceDiceIndicator = z.enum(["LOCAL_AVAILABILITY", "SUB_OD_AVAILABILITY_1", "SUB_OD_AVAILABILITY_2"]); export const baggageAllowance = z.object({quantity: z.number().int().optional(), weight: z.number().int().optional(), weightUnit: z.string().optional()}); export const chargeableCheckdBags = z.object({quantity: z.number().int().optional(), weight: z.number().int().optional(), weightUnit: z.string().optional(), id: z.string().optional()}); export const chargeableSeat = z.object({id: z.string().optional(), number: z.string().optional()}); export const serviceName = z.enum(["PRIORITY_BOARDING", "AIRPORT_CHECKIN"]); export const flightOffer = z.object({type: z.string(), id: z.string(), source: flightOfferSource.optional(), instantTicketingRequired: z.boolean().optional(), disablePricing: z.boolean().optional(), nonHomogeneous: z.boolean().optional(), oneWay: z.boolean().optional(), paymentCardRequired: z.boolean().optional(), lastTicketingDate: z.string().optional(), lastTicketingDateTime: z.string().optional(), numberOfBookableSeats: z.number().gte(1).lte(9).optional(), itineraries: z.array(z.object({duration: z.string().optional(), segments: z.array(segment)})).optional(), price: extendedPrice.optional(), pricingOptions: z.object({fareType: pricingOptionsFareType.optional(), includedCheckedBagsOnly: z.boolean().optional(), refundableFare: z.boolean().optional(), noRestrictionFare: z.boolean().optional(), noPenaltyFare: z.boolean().optional()}).optional(), validatingAirlineCodes: z.array(z.string()).optional(), travelerPricings: z.array(z.object({travelerId: z.string(), fareOption: travelerPricingFareOption, travelerType: travelerType, associatedAdultId: z.string().optional(), price: price.optional(), fareDetailsBySegment: z.array(z.object({segmentId: z.string(), cabin: travelClass.optional(), fareBasis: z.string().optional(), brandedFare: z.string().optional(), class: z.string().optional(), isAllotment: z.boolean().optional(), allotmentDetails: allotmentDetails.optional(), sliceDiceIndicator: sliceDiceIndicator.optional(), includedCheckedBags: baggageAllowance.optional(), additionalServices: z.object({chargeableCheckedBags: chargeableCheckdBags.optional(), chargeableSeat: chargeableSeat.optional(), chargeableSeatNumber: z.string().optional(), otherServices: z.array(serviceName).optional()}).optional()}))})).optional()}); export const stakeholderGender = z.enum(["MALE", "FEMALE", "UNSPECIFIED", "UNDISCLOSED"]); export const name = z.object({firstName: z.string().optional(), lastName: z.string().optional(), middleName: z.string().optional(), secondLastName: z.string().optional()}); export const documentType = z.enum(["VISA", "PASSPORT", "IDENTITY_CARD", "KNOWN_TRAVELER", "REDRESS"]); export const identityDocument = z.object({number: z.string().optional(), issuanceDate: z.string().optional(), expiryDate: z.string().optional(), issuanceCountry: z.string().optional(), issuanceLocation: z.string().optional(), nationality: z.string().optional(), birthPlace: z.string().optional(), documentType: documentType.optional(), validityCountry: z.string().optional(), birthCountry: z.string().optional(), holder: z.boolean().optional()}); export const emergencyContact = z.object({addresseeName: z.string().optional(), countryCode: z.string().optional(), number: z.string().optional(), text: z.string().optional()}); export const loyaltyProgram = z.object({programOwner: z.string().optional(), id: z.string().optional()}); export const discountType = z.enum(["SPANISH_RESIDENT", "AIR_FRANCE_DOMESTIC", "AIR_FRANCE_COMBINED", "AIR_FRANCE_METROPOLITAN"]); export const discountTravelerType = z.enum(["SPANISH_CITIZEN", "EUROPEAN_CITIZEN", "GOVERNMENT_WORKER", "MILITARY", "MINOR_WITHOUT_ID"]); export const discount = z.object({subType: discountType.optional(), cityName: z.string().optional(), travelerType: discountTravelerType.optional(), cardNumber: z.string().optional(), certificateNumber: z.string().optional()}); export const address = z.object({lines: z.array(z.string()).optional(), postalCode: z.string().optional(), countryCode: z.string().optional(), cityName: z.string().optional(), stateName: z.string().optional(), postalBox: z.string().optional()}); export const contactPurpose = z.enum(["STANDARD", "INVOICE", "STANDARD_WITHOUT_TRANSMISSION"]); export const phoneDeviceType = z.enum(["MOBILE", "LANDLINE", "FAX"]); export const phone = z.object({deviceType: phoneDeviceType.optional(), countryCallingCode: z.string().optional(), number: z.string().optional()}); export const contact = z.object({addresseeName: name.optional(), address: address.optional(), language: z.string().optional(), purpose: contactPurpose.optional(), phones: z.array(phone).optional(), companyName: z.string().optional(), emailAddress: z.string().optional()}); export const traveler = z.object({id: z.string().optional(), dateOfBirth: z.string().optional(), gender: stakeholderGender.optional(), name: name.optional(), documents: z.array(identityDocument).optional(), emergencyContact: emergencyContact.optional(), loyaltyPrograms: z.array(loyaltyProgram).optional(), discountEligibility: z.array(discount).optional(), contact: contact.optional()}); export const generalRemarkType = z.enum(["GENERAL_MISCELLANEOUS", "CONFIDENTIAL", "INVOICE", "QUALITY_CONTROL", "BACKOFFICE", "FULFILLMENT", "ITINERARY", "TICKETING_MISCELLANEOUS", "TOUR_CODE"]); export const generalRemark = z.object({subType: generalRemarkType, category: z.string().optional(), text: z.string(), travelerIds: z.array(z.string()).optional(), flightOfferIds: z.array(z.string()).optional()}); export const airlineRemarkType = z.enum(["OTHER_SERVICE_INFORMATION", "KEYWORD", "OTHER_SERVICE", "CLIENT_ID", "ADVANCED_TICKET_TIME_LIMIT"]); export const airlineRemark = z.object({subType: airlineRemarkType, keyword: z.string().optional(), airlineCode: z.string(), text: z.string(), travelerIds: z.array(z.string()).optional(), flightOfferIds: z.array(z.string()).optional()}); export const remarks = z.object({general: z.array(generalRemark).optional(), airline: z.array(airlineRemark).optional()}); export const creditCardBrand = z.enum(["VISA", "AMERICAN_EXPRESS", "MASTERCARD", "VISA_ELECTRON", "VISA_DEBIT", "MASTERCARD_DEBIT", "MAESTRO", "DINERS", "EASYPAY"]); export const virtualCreditCardDetails = z.object({brand: creditCardBrand.optional(), holder: z.string().optional(), number: z.string().optional(), expiryDate: z.string().optional(), amount: z.string().optional(), currencyCode: z.string().optional()}); export const b2bWallet = z.object({cardId: z.string().optional(), cardUsageName: z.string().optional(), cardFriendlyName: z.string().optional(), reportingData: z.array(z.object({name: z.string().optional(), value: z.string().optional()})).optional(), virtualCreditCardDetails: virtualCreditCardDetails.optional(), flightOfferIds: z.array(z.string()).optional()}); export const creditCard = z.object({brand: creditCardBrand.optional(), holder: z.string().optional(), number: z.string().optional(), expiryDate: z.string().optional(), securityCode: z.string().optional(), flightOfferIds: z.array(z.string()).optional()}); export const otherPaymentMethod = z.enum(["ACCOUNT", "CHECK", "CASH", "NONREFUNDABLE"]); export const otherMethod = z.object({method: otherPaymentMethod.optional(), flightOfferIds: z.array(z.string()).optional()}); export const formOfPayment = z.object({b2bWallet: b2bWallet.optional(), creditCard: creditCard.optional(), other: otherMethod.optional()}); export const ticketingAgreementOption = z.enum(["CONFIRM", "DELAY_TO_QUEUE", "DELAY_TO_CANCEL"]); export const ticketingAgreement = z.object({option: ticketingAgreementOption.optional(), delay: z.string().optional(), dateTime: z.string().optional(), segmentIds: z.array(z.string()).optional()}); export const automatedProcessCode = z.enum(["IMMEDIATE", "DELAYED", "ERROR"]); export const automatedProcess = z.object({code: automatedProcessCode.optional(), queue: z.object({number: z.string().optional(), category: z.string().optional()}).optional(), text: z.string().optional(), delay: z.string().optional(), officeId: z.string().optional(), dateTime: z.string().optional()}); export const airTravelDocument = z.object({documentType: z.enum(["ETICKET", "PTICKET", "EMD", "MCO"]).optional(), documentNumber: z.string().optional(), documentStatus: z.enum(["ISSUED", "REFUNDED", "VOID", "ORIGINAL", "EXCHANGED"]).optional(), travelerId: z.string().optional(), segmentIds: z.array(z.string()).optional()}); export const formOfIdentification = z.object({identificationType: z.enum(["DRIVERS_LICENSE", "PASSPORT", "NATIONAL_IDENTITY_CARD", "BOOKING_CONFIRMATION", "TICKET", "OTHER_ID"]).optional(), carrierCode: z.string().min(1).max(2).optional(), number: z.string().optional(), travelerIds: z.array(z.string()).optional(), flightOfferIds: z.array(z.string()).optional()}); export const flightOrder = z.object({type: z.string(), id: z.string().optional(), queuingOfficeId: z.string().optional(), ownerOfficeId: z.string().optional(), associatedRecords: z.array(associatedRecord).optional(), flightOffers: z.array(flightOffer), travelers: z.array(traveler).optional(), remarks: remarks.optional(), formOfPayments: z.array(formOfPayment).optional(), ticketingAgreement: ticketingAgreement.optional(), automatedProcess: z.array(automatedProcess).optional(), contacts: z.array(contact).optional(), tickets: z.array(airTravelDocument).optional(), formOfIdentifications: z.array(formOfIdentification).optional()}); export const locationEntry = z.unknown(); export const aircraftEntry = z.unknown(); export const currencyEntry = z.unknown(); export const carrierEntry = z.unknown(); export const dictionaries = z.object({locations: locationEntry.optional(), aircraft: aircraftEntry.optional(), currencies: currencyEntry.optional(), carriers: carrierEntry.optional()}); export const createApiBookingFlightOrdersResponse = z.object({meta: collectionMetaLink.optional(), warnings: z.array(issue).optional(), data: flightOrder, dictionaries: dictionaries.optional()}); 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 }; /** * Create Order associated to the Flight offers. * * POST /booking/flight-orders */ export const createApiBookingFlightOrders = async (args: CreateApiBookingFlightOrdersArgs, options?: CreateApiBookingFlightOrdersOptions) => { const {baseUrl = "https://test.api.amadeus.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.amadeus+json") headers.set('accept', "application/vnd.amadeus+json") const url = `${baseUrl.replace(/\/+$/, '')}/booking/flight-orders${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 validateResponse(createApiBookingFlightOrdersResponse, await res.json()) };