File tree Expand file tree Collapse file tree 5 files changed +103
-1
lines changed
Expand file tree Collapse file tree 5 files changed +103
-1
lines changed Original file line number Diff line number Diff line change @@ -447,6 +447,13 @@ describe('Namespaces', () => {
447447 . toHaveBeenCalledWith ( '/v1/booking/hotel-bookings' , { } ) ;
448448 } ) ;
449449
450+ it ( '.amadeus.booking.hotelOrders.post' , ( ) => {
451+ amadeus . client . post = jest . fn ( ) ;
452+ amadeus . booking . hotelOrders . post ( ) ;
453+ expect ( amadeus . client . post )
454+ . toHaveBeenCalledWith ( '/v2/booking/hotel-orders' , { } ) ;
455+ } ) ;
456+
450457 it ( '.amadeus.eReputation.hotelSentiments.get' , ( ) => {
451458 amadeus . client . get = jest . fn ( ) ;
452459 amadeus . eReputation . hotelSentiments . get ( ) ;
Original file line number Diff line number Diff line change 11import FlightOrders from './booking/flight_orders' ;
22import FlightOrder from './booking/flight_order' ;
33import HotelBookings from './booking/hotel_bookings' ;
4+ import HotelOrders from './booking/hotel_orders' ;
45
56/**
67 * A namespaced client for the
@@ -17,13 +18,15 @@ import HotelBookings from './booking/hotel_bookings';
1718 * @property {FlightOrders } flightOrders
1819 * @property {FlightOrder } flightOrder
1920 * @property {HotelBookings } hotelBookings
21+ * @property {HotelOrders } hotelOrders
2022 * @protected
2123 */
2224class Booking {
2325 constructor ( client ) {
2426 this . client = client ;
2527 this . flightOrders = new FlightOrders ( client ) ;
2628 this . hotelBookings = new HotelBookings ( client ) ;
29+ this . hotelOrders = new HotelOrders ( client ) ;
2730 }
2831
2932 flightOrder ( orderId ) {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class FlightOrders {
2828 * amadeus.booking.flightOrders.post({
2929 * 'type': 'flight-order',
3030 * 'flightOffers': [],
31- * 'travelers_info ': []
31+ * 'traveler ': []
3232 * });
3333 * ```
3434 */
Original file line number Diff line number Diff line change 1+ /**
2+ * A namespaced client for the
3+ * `/v2/booking/hotel-orders` endpoints
4+ *
5+ * Access via the {@link Amadeus} object
6+ *
7+ * ```js
8+ * let amadeus = new Amadeus();
9+ * amadeus.booking.hotelOrders;
10+ * ```
11+ *
12+ * @param {Client } client
13+ */
14+ class HotelOrders {
15+ constructor ( client ) {
16+ this . client = client ;
17+ }
18+
19+ /**
20+ * To book the offer retrieved from Hotel Search API.
21+ *
22+ * @param {Object } params
23+ * @return {Promise.<Response,ResponseError> } a Promise
24+ *
25+ * To book the hotel offer with ID 'XXX' with guests, travel agents and payment info
26+ *
27+ * ```js
28+ * amadeus.booking.hotelOrders.post({
29+ * 'guests': [],
30+ * 'travel_agent: {},
31+ * 'room_associations: [],
32+ * 'payment': {}
33+ * });
34+ * ```
35+ */
36+ post ( params = { } ) {
37+ const body = {
38+ data : {
39+ type : 'hotel-order' ,
40+ guests : params . guests || [ ] ,
41+ travelAgent : params . travelAgent || { } ,
42+ roomAssociations : params . roomAssociations || [ ] ,
43+ payment : params . payment || { } ,
44+ arrivalInformation : params . arrivalInformation || { }
45+ }
46+ } ;
47+
48+ return this . client . post ( '/v2/booking/hotel-orders' , JSON . stringify ( body ) ) ;
49+ }
50+ }
51+
52+ export default HotelOrders ;
Original file line number Diff line number Diff line change 1+ var Amadeus = require ( './lib/amadeus' ) ;
2+
3+ var amadeus = new Amadeus ( {
4+ clientId : '8nO6oq4ywwDlqZG3btuBy7bkSoAjZGdn' ,
5+ clientSecret : 'BJyF3fvNG9frmkAE' ,
6+ logLevel : 'debug'
7+ } ) ;
8+
9+ body = {
10+ "originDestinations" : [
11+ {
12+ "id" : "1" ,
13+ "originLocationCode" : "BOS" ,
14+ "destinationLocationCode" : "MAD" ,
15+ "departureDateTime" : {
16+ "date" : "{{departureDate}}" ,
17+ "time" : "21:15:00"
18+ }
19+ }
20+ ] ,
21+ "travelers" : [
22+ {
23+ "id" : "1" ,
24+ "travelerType" : "ADULT"
25+ } ,
26+ {
27+ "id" : "2" ,
28+ "travelerType" : "CHILD"
29+ }
30+ ] ,
31+ "sources" : [
32+ "GDS"
33+ ]
34+ }
35+
36+ amadeus . shopping . availability . flightAvailabilities . post ( body ) . then ( function ( response ) {
37+ console . log ( response ) ;
38+ } ) . catch ( function ( response ) {
39+ console . error ( response ) ;
40+ } ) ;
You can’t perform that action at this time.
0 commit comments