Skip to content
Permalink
Newer
Older
100644 66 lines (65 sloc) 1.79 KB
1
var Amadeus = require('amadeus');
2
var amadeus = new Amadeus({
3
clientId: 'YOUR_API_KEY',
4
clientSecret: 'YOUR_API_SECRET'
5
});
6
7
// Book a flight from MAD to ATH on 2022-08-01
8
amadeus.shopping.flightOffersSearch.get({
9
originLocationCode: 'MAD',
10
destinationLocationCode: 'ATH',
11
departureDate: '2022-08-01',
12
adults: '1'
13
}).then(function (flightOffersResponse) {
14
return amadeus.shopping.flightOffers.pricing.post(
15
JSON.stringify({
16
"data": {
17
"type": "flight-offers-pricing",
18
"flightOffers": [
19
flightOffersResponse.data[0]
20
]
21
}
22
})
23
);
24
}).then(function (pricingResponse) {
25
return amadeus.booking.flightOrders.post(
26
JSON.stringify({
27
'data': {
28
'type': 'flight-order',
29
'flightOffers': [pricingResponse.data.flightOffers[0]],
30
'travelers': [{
31
"id": "1",
32
"dateOfBirth": "1982-01-16",
33
"name": {
34
"firstName": "JORGE",
35
"lastName": "GONZALES"
36
},
37
"gender": "MALE",
38
"contact": {
39
"emailAddress": "jorge.gonzales833@telefonica.es",
40
"phones": [{
41
"deviceType": "MOBILE",
42
"countryCallingCode": "34",
43
"number": "480080076"
44
}]
45
},
46
"documents": [{
47
"documentType": "PASSPORT",
48
"birthPlace": "Madrid",
49
"issuanceLocation": "Madrid",
50
"issuanceDate": "2015-04-14",
51
"number": "00000000",
52
"expiryDate": "2025-04-14",
53
"issuanceCountry": "ES",
54
"validityCountry": "ES",
55
"nationality": "ES",
56
"holder": true
57
}]
58
}]
59
}
60
})
61
);
62
}).then(function (response) {
63
console.log(response);
64
}).catch(function (response) {
65
console.error(response);