Skip to content

Commit 2632d76

Browse files
Add example for Flight Create Orders and Orders Management (#68)
* add example for create orders management * test new example in travis * revert travis * add typerror to exception * beautify traveler info and comment each call and error * change traveler format * revert example * update create orders example * clean file * revert to correct example * update tox * add tox:travis * chanve venv version Co-authored-by: Anthony Roux <[email protected]>
1 parent 647a028 commit 2632d76

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from amadeus import Client, ResponseError
2+
3+
amadeus = Client()
4+
5+
traveler = {
6+
'id': '1',
7+
'dateOfBirth': '1982-01-16',
8+
'name': {
9+
'firstName': 'JORGE',
10+
'lastName': 'GONZALES'
11+
},
12+
'gender': 'MALE',
13+
'contact': {
14+
'emailAddress': '[email protected]',
15+
'phones': [{
16+
'deviceType': 'MOBILE',
17+
'countryCallingCode': '34',
18+
'number': '480080076'
19+
}]
20+
},
21+
'documents': [{
22+
'documentType': 'PASSPORT',
23+
'birthPlace': 'Madrid',
24+
'issuanceLocation': 'Madrid',
25+
'issuanceDate': '2015-04-14',
26+
'number': '00000000',
27+
'expiryDate': '2025-04-14',
28+
'issuanceCountry': 'ES',
29+
'validityCountry': 'ES',
30+
'nationality': 'ES',
31+
'holder': True
32+
}]
33+
}
34+
35+
try:
36+
# Flight Offers Search to search for flights from MAD to ATH
37+
# print('Flight Offers Search')
38+
flight_search = amadeus.shopping.flight_offers_search.get(originLocationCode='MAD',
39+
destinationLocationCode='ATH',
40+
departureDate='2020-12-01',
41+
adults=1).data
42+
# Flight Offers Price to confirm the price of the chosen flight
43+
# print('Flight Offers Price')
44+
price_confirm = amadeus.shopping.flight_offers.pricing.post(flight_search[0]).data
45+
# Flight Create Orders to book the flight
46+
# print('Flight Create Orders')
47+
booked_flight = amadeus.booking.flight_orders.post(flight_search[0], traveler).data
48+
# Flight Order Management returns the last-updated version of the booking
49+
# print('Flight Order Management')
50+
updated_booking = amadeus.booking.flight_order(booked_flight['id']).get()
51+
except ResponseError as error:
52+
# print(error.response.body)
53+
pass

0 commit comments

Comments
 (0)