Skip to content

Commit bcbd08c

Browse files
authored
Merge pull request #148 from amadeus4dev/add-hotel-search-v3-only
add hotel search v3, keep v2
2 parents 30ba034 + e0855ac commit bcbd08c

File tree

5 files changed

+128
-2
lines changed

5 files changed

+128
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ amadeus.shopping.hotelOffersByHotel.get({
374374
// Confirm the availability of a specific offer id
375375
amadeus.shopping.hotelOffer('XXX').get()
376376

377+
// Hotel Search API V3
378+
// Get list of available offers in specific hotels by hotel ids
379+
amadeus.shopping.hotelOffersSearch.get({
380+
hotelIds: 'RTPAR001',
381+
adults: '2'
382+
})
383+
// Check offer conditions of a specific offer id
384+
amadeus.shopping.hotelOfferSearch('XXX').get()
385+
377386
// Hotel Booking API
378387
amadeus.booking.hotelBookings.post(
379388
JSON.stringify({

spec/amadeus/namespaces.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ describe('Namespaces', () => {
6969
expect(amadeus.shopping.hotelOffersByHotel).toBeDefined();
7070
expect(amadeus.shopping.hotelOffer).toBeDefined();
7171

72+
expect(amadeus.shopping.hotelOfferSearch).toBeDefined();
73+
expect(amadeus.shopping.hotelOffersSearch).toBeDefined();
74+
7275
expect(amadeus.shopping.availability).toBeDefined();
7376
expect(amadeus.shopping.availability.flightAvailabilities).toBeDefined();
7477

@@ -131,6 +134,9 @@ describe('Namespaces', () => {
131134
expect(amadeus.shopping.hotelOffersByHotel.get).toBeDefined();
132135
expect(amadeus.shopping.hotelOffer('XXX').get).toBeDefined();
133136

137+
expect(amadeus.shopping.hotelOfferSearch('XXX').get).toBeDefined();
138+
expect(amadeus.shopping.hotelOffersSearch.get).toBeDefined();
139+
134140
expect(amadeus.shopping.activities.get).toBeDefined();
135141
expect(amadeus.shopping.activities.bySquare.get).toBeDefined();
136142
expect(amadeus.shopping.activity('XXX').get).toBeDefined();
@@ -399,6 +405,20 @@ describe('Namespaces', () => {
399405
.toHaveBeenCalledWith('/v2/shopping/hotel-offers/XXX', {});
400406
});
401407

408+
it('.amadeus.shopping.hotelOfferSearch().get', () => {
409+
amadeus.client.get = jest.fn();
410+
amadeus.shopping.hotelOfferSearch('XXX').get();
411+
expect(amadeus.client.get)
412+
.toHaveBeenCalledWith('/v3/shopping/hotel-offers/XXX', {});
413+
});
414+
415+
it('.amadeus.shopping.hotelOffersSearch.get', () => {
416+
amadeus.client.get = jest.fn();
417+
amadeus.shopping.hotelOffersSearch.get();
418+
expect(amadeus.client.get)
419+
.toHaveBeenCalledWith('/v3/shopping/hotel-offers', {});
420+
});
421+
402422
it('.amadeus.shopping.activities.get', () => {
403423
amadeus.client.get = jest.fn();
404424
amadeus.shopping.activities.get();

src/amadeus/namespaces/shopping.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import Seatmaps from './shopping/seatmaps';
66
import HotelOffers from './shopping/hotel_offers';
77
import HotelOffersByHotel from './shopping/hotel_offers_by_hotel';
88
import HotelOffer from './shopping/hotel_offer';
9+
import HotelOfferSearch from './shopping/hotel_offer_search';
10+
import HotelOffersSearch from './shopping/hotel_offers_search';
911
import Activities from './shopping/activities';
1012
import Activity from './shopping/activity';
1113
import Availability from './shopping/availability';
1214

1315

1416
/**
1517
* A namespaced client for the
16-
* `/v1/shopping` and `/v2/shopping` endpoints
18+
* `/v1/shopping`, `/v2/shopping` and `/v3/shopping` endpoints
1719
*
1820
* Access via the {@link Amadeus} object
1921
*
@@ -31,6 +33,8 @@ import Availability from './shopping/availability';
3133
* @property {HotelOffers} hotelOffers
3234
* @property {HotelOffer} hotelOffer
3335
* @property {HotelOffersByHotel} hotelOffersByHotel
36+
* @property {HotelOfferSearch} hotelOffers
37+
* @property {HotelOffersSearch} hotelOffers
3438
* @property {Availability} availability
3539
*/
3640
class Shopping {
@@ -43,13 +47,14 @@ class Shopping {
4347
this.seatmaps = new Seatmaps(client);
4448
this.hotelOffers = new HotelOffers(client);
4549
this.hotelOffersByHotel = new HotelOffersByHotel(client);
50+
this.hotelOffersSearch = new HotelOffersSearch(client);
4651
this.activities = new Activities(client);
4752
this.availability = new Availability(client);
4853
}
4954

5055

5156
/**
52-
* Loads a namespaced path for a specific offer ID
57+
* Loads a namespaced path for a specific offer ID for Hotel Search V2
5358
*
5459
* @param {string} [offerId] The ID of the offer for a dedicated hotel
5560
* @return {HotelOffer}
@@ -58,6 +63,16 @@ class Shopping {
5863
return new HotelOffer(this.client, offerId);
5964
}
6065

66+
/**
67+
* Loads a namespaced path for a specific offer ID for Hotel Search V3
68+
*
69+
* @param {string} [offerId] The ID of the offer for a dedicated hotel
70+
* @return {HotelOfferSearch}
71+
**/
72+
hotelOfferSearch(offerId) {
73+
return new HotelOfferSearch(this.client, offerId);
74+
}
75+
6176
/**
6277
* Loads a namespaced path for a specific activity ID
6378
*
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v3/shopping/hotel-offers/:offer_id` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.shopping.hotelOfferSearch('XXX');
10+
* ```
11+
*
12+
* @param {Client} client
13+
* @property {number} offerId
14+
*/
15+
class hotelOfferSearch {
16+
constructor(client, offerId) {
17+
this.client = client;
18+
this.offerId = offerId;
19+
}
20+
21+
/**
22+
* Returns details for a specific offer
23+
*
24+
* @param {Object} params
25+
* @return {Promise.<Response,ResponseError>} a Promise
26+
*
27+
* Find details for the offer with ID 'XXX'
28+
*
29+
* ```js
30+
* amadeus.shopping.hotelOfferSearch('XXX').get();
31+
* ```
32+
*/
33+
get(params = {}) {
34+
return this.client.get(
35+
`/v3/shopping/hotel-offers/${this.offerId}`, params
36+
);
37+
}
38+
}
39+
40+
export default hotelOfferSearch;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v3/shopping/hotel-offers` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.shopping.hotelOffersSearch;
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class hotelOffersSearch {
15+
constructor(client) {
16+
this.client = client;
17+
}
18+
19+
/**
20+
* Find the list of available offers in the specific hotels
21+
*
22+
* @param {Object} params
23+
* @param {string} params.hotelIds Comma separated list of Amadeus hotel
24+
* codes to request. Example: RTPAR001
25+
* @param {string} params.adults Number of adult guests (1-9) per room.
26+
* @return {Promise.<Response,ResponseError>} a Promise
27+
*
28+
* Search for available offers in Novotel Paris for 2 adults
29+
*
30+
* ```js
31+
* amadeus.shopping.hotelOffersSearch.get({
32+
* hotelIds: 'RTPAR001',
33+
* adults: '2'
34+
* })
35+
* ```
36+
*/
37+
get(params = {}) {
38+
return this.client.get('/v3/shopping/hotel-offers', params);
39+
}
40+
}
41+
42+
export default hotelOffersSearch;

0 commit comments

Comments
 (0)