
hide footbox

actor Retailer 

== Creating the trip collection & getting the initial set of trips ==
Retailer -> Distributor: POST /trips-collection\n <MUNCHEN-PARIS, 23/10/2021, 2 pax, dob, ...>
Distributor -> Journey_Planner : <retrieve trips information based on API Consumer request>
Journey_Planner --> Distributor : <trips information>
loop for each trip    
    loop for each segment
        Distributor -> Distributor: determine FareProvider
    end
end
Distributor -> Distributor : create offer requests

== Retrieving offers collection ==

Distributor -> FareProvider1: POST /offers-collection
FareProvider1 -> FareProvider1: calculate offers
FareProvider1 --> Distributor : request with trips
Distributor -> FareProvider2: POST /offers-collection 
FareProvider2 -> FareProvider2: calculate offers
FareProvider2 --> Distributor : request with trips
Distributor -> Distributor : reconcile trips and \nconstruct global offers
Distributor --> Retailer: <Offers-Collection with list of references to offers>

== Creating a booking based on one or more offer(s) ==
Retailer -> Distributor: POST /bookings/ <offerId= 8765> with place selection
Distributor -> Distributor : create local booking 5678
Distributor -> FareProvider1: provisionally book offerpart1 
FareProvider1 -> FareProvider1: create FareProvider booking
FareProvider1 --> Distributor : OK response (can vary per FareProvider)
Distributor -> Distributor : add FareProvider booking to local booking
Distributor -> FareProvider2: provisionally book offerpart2 
FareProvider2 -> FareProvider2: create FareProvider booking
FareProvider2 --> Distributor : OK response (can vary per FareProvider)
Distributor -> Distributor : add FareProvider booking to local booking
Distributor --> Retailer: <Created Booking 5678>

== Setting additional passenger information that may be required to confirm the booking, starting from the booking overview ==
Retailer -> Distributor: GET /bookings/5678
Distributor --> Retailer: <Booking with booked offers and passengers resources>
Retailer -> Retailer: check booking RequestedInformation
Retailer -> Distributor: PATCH /bookings/5678/passengers/123/ < additional information for passenger>
Distributor -> FareProvider1: update passenger data 
FareProvider1 --> Distributor : OK response (can vary per FareProvider)
Distributor -> FareProvider2: update passenger data 
FareProvider2 --> Distributor : OK response (can vary per FareProvider)
Distributor -> Distributor : update local booking 5678
Distributor --> Retailer: <passenger 123 updated with the added information>

== Setting fulfillment type for the booking ==
Distributor --> Retailer: <Booking with only references to embedded resources>
Retailer -> Distributor: PATCH /bookings/5678 <setting the fulfillmentOptions>
Distributor --> Retailer: <Booking resource with updated fulfillmentOptions>

== Confirming booking & triggering fulfillment ==
Retailer -> Distributor: POST /bookings/5678/fulfillments
Distributor -> FareProvider1: confirm & fulfill booking 
FareProvider1 --> Distributor : OK response (can vary per FareProvider)
Distributor -> FareProvider2: confirm & fulfill booking 
FareProvider2 --> Distributor : OK response (can vary per FareProvider)
Distributor -> Distributor: update local statuses & create fulfillment resources
Distributor --> Retailer: <Fulfillments created in the booking 5678>
