Skip to content

Commit e36bf31

Browse files
Ree-makerreejoseph
andauthored
test(flight-details): validate Flight Details SDK (#145)
Co-authored-by: reejoseph <[email protected]>
1 parent d77dd78 commit e36bf31

File tree

1 file changed

+262
-0
lines changed

1 file changed

+262
-0
lines changed
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
/*
2+
* Copyright (C) 2025 Expedia, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.expediagroup.sdk.xap.examples.scenarios.flight;
18+
19+
import com.expediagroup.sdk.xap.client.XapClient;
20+
import com.expediagroup.sdk.xap.examples.scenarios.XapScenario;
21+
import com.expediagroup.sdk.xap.models.FlightDetailsResponse;
22+
import com.expediagroup.sdk.xap.operations.GetFlightDetailsOperation;
23+
import com.expediagroup.sdk.xap.operations.GetFlightDetailsOperationParams;
24+
25+
import java.time.LocalDate;
26+
import java.util.Arrays;
27+
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
30+
31+
/**
32+
* This example demonstrates how to make Details API Call to get extended information about
33+
* fare, charges, fees, other terms associated with booking an airline ticket.
34+
*/
35+
36+
public class FlightDetailsExample implements XapScenario {
37+
38+
private static final Logger LOGGER =
39+
LoggerFactory.getLogger(FlightDetailsExample.class);
40+
41+
42+
public static void main(String[] args) {
43+
new FlightDetailsExample().run();
44+
System.exit(0);
45+
}
46+
47+
@Override
48+
public void run() {
49+
LOGGER.info(
50+
"========= Running FlightDetailsQuickStartScenario =============");
51+
52+
LOGGER.info(
53+
"============= Executing GetFlightDetailsOperation =========");
54+
55+
GetFlightDetailsOperationParams detailsOperationParams = GetFlightDetailsOperationParams
56+
.builder()
57+
.offerToken("v5-sos-f7f6baebb159423791c2583b1dfd22b7-14-1~8.S~AQoECL"
58+
+ "-kBBIICNQEEAEYwB8oAlgBcAB6BXNhYnJliAHczsZQqgEHCgNMQVgQALIBB"
59+
+ "woDU0VBEAA~AQotCisIwaYBEgQxMzA1GIu4ASCSASiUuPoCML25-gI4T0AA"
60+
+ "WAFyCE9IMk9YVU1OEgoIARABGAEqAkFTGAEiBAgBEAEoAigDKAQwAg")
61+
.partnerTransactionID("txn-123-4")
62+
.price("123.31")
63+
.locale("en_US")
64+
.build();
65+
XapClient xapClient = createClient();
66+
67+
FlightDetailsResponse flightDetailsResponse =
68+
xapClient.execute(new GetFlightDetailsOperation(detailsOperationParams))
69+
.getData();
70+
71+
LOGGER.info("========= GetFlightDetailsOperation Executed ========");
72+
73+
LOGGER.info("Transaction ID: {}", flightDetailsResponse.getTransactionId());
74+
75+
if (flightDetailsResponse.getSegments() != null) {
76+
flightDetailsResponse.getSegments().forEach(segment -> {
77+
LOGGER.info("======================== Flight Segment Start ========================");
78+
LOGGER.info("Segment ID: {}", segment.getSegmentId());
79+
LOGGER.info("Flight Duration: {}", segment.getFlightDuration());
80+
LOGGER.info("Total Stops: {}", segment.getTotalStops());
81+
LOGGER.info("Departure Arrival Day Difference: {}",
82+
segment.getDepartureArrivalDayDifference());
83+
LOGGER.info("Fare Type: {}", segment.getFareType());
84+
LOGGER.info("Airport Change: {}", segment.getAirportChange());
85+
86+
if (segment.getLegs() != null) {
87+
segment.getLegs().forEach(leg -> {
88+
LOGGER.info("-------------------- Leg Start --------------------");
89+
90+
if (leg.getDepartureAirport() != null) {
91+
LOGGER.info("Departure Airport Code: {}",
92+
leg.getDepartureAirport().getCode());
93+
}
94+
95+
if (leg.getArrivalAirport() != null) {
96+
LOGGER.info("Arrival Airport Code: {}",
97+
leg.getArrivalAirport().getCode());
98+
}
99+
LOGGER.info("Departure Date Time: {}",
100+
leg.getDepartureDateTime());
101+
LOGGER.info("Arrival Date Time: {}",
102+
leg.getArrivalDateTime());
103+
LOGGER.info("Flight Number: {}",
104+
leg.getFlightNumber());
105+
LOGGER.info("Marketing Airline Code: {}",
106+
leg.getMarketingAirlineCode());
107+
LOGGER.info("Marketing Airline Name: {}",
108+
leg.getMarketingAirlineName());
109+
LOGGER.info("Equipment Code: {}",
110+
leg.getEquipmentCode());
111+
LOGGER.info("Flight On Time Percentage: {}",
112+
leg.getFlightOnTimePercentage());
113+
LOGGER.info("Equipment Name: {}",
114+
leg.getEquipmentName());
115+
LOGGER.info("Flight Duration (Leg): {}",
116+
leg.getFlightDuration());
117+
118+
if (leg.getFlightDistance() != null) {
119+
LOGGER.info("Flight Distance Value: {}",
120+
leg.getFlightDistance().getValue());
121+
LOGGER.info("Flight Distance Unit: {}",
122+
leg.getFlightDistance().getUnit());
123+
}
124+
LOGGER.info("Booking Code: {}",
125+
leg.getBookingCode());
126+
LOGGER.info("Cabin Class: {}",
127+
leg.getCabinClass());
128+
LOGGER.info("Fare Basis Code: {}",
129+
leg.getFareBasisCode());
130+
LOGGER.info("Meal Options: {}",
131+
leg.getMealOptions());
132+
LOGGER.info("Amenities: {}",
133+
leg.getAmenities());
134+
LOGGER.info("---------- Leg End ----------");
135+
});
136+
}
137+
LOGGER.info("=========== Flight Segment End ============");
138+
});
139+
}
140+
141+
if (flightDetailsResponse.getOffer() != null) {
142+
LOGGER.info("======================== Flight Offer Start ========================");
143+
144+
if (flightDetailsResponse.getOffer().getLinks() != null) {
145+
flightDetailsResponse.getOffer().getLinks().forEach((key, value) ->
146+
LOGGER.info("Link [{}]: {}", key, value));
147+
}
148+
149+
LOGGER.info("Segment IDs: {}", flightDetailsResponse.getOffer().getSegmentIds());
150+
LOGGER.info("Refundable: {}", flightDetailsResponse.getOffer().getRefundable());
151+
LOGGER.info("International: {}", flightDetailsResponse.getOffer().getInternational());
152+
LOGGER.info("UndisclosedGenderSupported: {}",
153+
flightDetailsResponse.getOffer().getUndisclosedGenderSupported());
154+
LOGGER.info("UnspecifiedGenderSupported: {}",
155+
flightDetailsResponse.getOffer().getUnspecifiedGenderSupported());
156+
157+
if (flightDetailsResponse.getOffer().getOfferPrice() != null) {
158+
159+
if (flightDetailsResponse.getOffer().getOfferPrice().getTotalPrice() != null) {
160+
LOGGER.info("Total Price Value: {}",
161+
flightDetailsResponse.getOffer().getOfferPrice().getTotalPrice().getValue());
162+
LOGGER.info("Total Price Currency: {}",
163+
flightDetailsResponse.getOffer().getOfferPrice().getTotalPrice().getCurrency());
164+
}
165+
166+
if (flightDetailsResponse.getOffer().getOfferPrice().getBasePrice() != null) {
167+
LOGGER.info("Base Price Value: {}",
168+
flightDetailsResponse.getOffer().getOfferPrice().getBasePrice().getValue());
169+
LOGGER.info("Base Price Currency: {}",
170+
flightDetailsResponse.getOffer().getOfferPrice().getBasePrice().getCurrency());
171+
}
172+
173+
if (flightDetailsResponse.getOffer().getOfferPrice().getTotalTaxes() != null) {
174+
LOGGER.info("Total Taxes Value: {}",
175+
flightDetailsResponse.getOffer().getOfferPrice().getTotalTaxes().getValue());
176+
LOGGER.info("Total Taxes Currency: {}",
177+
flightDetailsResponse.getOffer().getOfferPrice().getTotalTaxes().getCurrency());
178+
}
179+
180+
if (flightDetailsResponse.getOffer().getOfferPrice().getTotalTaxesAndFees() != null) {
181+
LOGGER.info("Total Taxes and Fees Value: {}",
182+
flightDetailsResponse.getOffer()
183+
.getOfferPrice().getTotalTaxesAndFees().getValue());
184+
LOGGER.info("Total Taxes and Fees Currency: {}",
185+
flightDetailsResponse.getOffer()
186+
.getOfferPrice().getTotalTaxesAndFees().getCurrency());
187+
}
188+
189+
if (flightDetailsResponse.getOffer().getOfferPrice().getAveragePricePerTicket() != null) {
190+
LOGGER.info("Average Price Per Ticket Value: {}",
191+
flightDetailsResponse.getOffer()
192+
.getOfferPrice().getAveragePricePerTicket().getValue());
193+
LOGGER.info("Average Price Per Ticket Currency: {}",
194+
flightDetailsResponse.getOffer()
195+
.getOfferPrice().getAveragePricePerTicket().getCurrency());
196+
LOGGER.info("Average Price Per Ticket Count: {}",
197+
flightDetailsResponse.getOffer()
198+
.getOfferPrice().getAveragePricePerTicket().getCount());
199+
}
200+
201+
if (flightDetailsResponse.getOffer()
202+
.getOfferPrice().getPricePerPassengerCategory() != null) {
203+
flightDetailsResponse.getOffer().getOfferPrice().getPricePerPassengerCategory()
204+
.forEach(categoryPrice -> {
205+
LOGGER.info("---- Passenger Category Price Start ----");
206+
LOGGER.info("Category: {}", categoryPrice.getCategory());
207+
LOGGER.info("Count: {}", categoryPrice.getCount());
208+
209+
if (categoryPrice.getTotalPrice() != null) {
210+
LOGGER.info("Total Price Value: {}",
211+
categoryPrice.getTotalPrice().getValue());
212+
LOGGER.info("Total Price Currency: {}",
213+
categoryPrice.getTotalPrice().getCurrency());
214+
}
215+
216+
if (categoryPrice.getBasePrice() != null) {
217+
LOGGER.info("Base Price Value: {}",
218+
categoryPrice.getBasePrice().getValue());
219+
LOGGER.info("Base Price Currency: {}",
220+
categoryPrice.getBasePrice().getCurrency());
221+
}
222+
223+
if (categoryPrice.getTotalTaxes() != null) {
224+
LOGGER.info("Total Taxes Value: {}",
225+
categoryPrice.getTotalTaxes().getValue());
226+
LOGGER.info("Total Taxes Currency: {}",
227+
categoryPrice.getTotalTaxes().getCurrency());
228+
}
229+
LOGGER.info("---- Passenger Category Price End ----");
230+
});
231+
}
232+
}
233+
234+
235+
LOGGER.info("Ticket Type: {}", flightDetailsResponse.getOffer().getTicketType());
236+
LOGGER.info("======================== Flight Offer End ========================");
237+
}
238+
239+
if (flightDetailsResponse.getValidFormsOfPayment() != null) {
240+
flightDetailsResponse.getValidFormsOfPayment().forEach((value) -> {
241+
LOGGER.info("========== Valid Forms of Payment End [{}] ============");
242+
LOGGER.info("---- Payment Method Start ----");
243+
LOGGER.info("Payment Method: {}", value.getPaymentMethod());
244+
LOGGER.info("Name: {}", value.getName());
245+
LOGGER.info("Fee: {}", value.getFee());
246+
LOGGER.info("Currency: {}", value.getCurrency());
247+
LOGGER.info("---- Payment Method End ----");
248+
LOGGER.info("========== Valid Forms of Payment End [{}] ============");
249+
});
250+
}
251+
252+
LOGGER.info(
253+
"===================== End FlightListingsQuickStartScenario ====================");
254+
}
255+
256+
}
257+
258+
259+
260+
261+
262+

0 commit comments

Comments
 (0)