Skip to content

Commit 2fc502d

Browse files
committed
add trip parser v3 and remove v2
1 parent 6bbeeed commit 2fc502d

File tree

5 files changed

+45
-138
lines changed

5 files changed

+45
-138
lines changed

spec/amadeus/namespaces.test.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ describe('Namespaces', () => {
4747
expect(amadeus.travel.predictions).toBeDefined();
4848
expect(amadeus.travel.predictions.tripPurpose).toBeDefined();
4949
expect(amadeus.travel.predictions.flightDelay).toBeDefined();
50-
expect(amadeus.travel.tripParserJobs).toBeDefined();
51-
expect(amadeus.travel.tripParserJobs('XXX').result).toBeDefined();
50+
expect(amadeus.travel.tripParser).toBeDefined();
5251

5352
expect(amadeus.shopping).toBeDefined();
5453
expect(amadeus.shopping.flightDates).toBeDefined();
@@ -126,8 +125,6 @@ describe('Namespaces', () => {
126125
expect(amadeus.travel.analytics.airTraffic.busiestPeriod.get).toBeDefined();
127126
expect(amadeus.travel.predictions.tripPurpose.get).toBeDefined();
128127
expect(amadeus.travel.predictions.flightDelay.get).toBeDefined();
129-
expect(amadeus.travel.tripParserJobs('XXX').get).toBeDefined();
130-
expect(amadeus.travel.tripParserJobs('XXX').result.get).toBeDefined();
131128

132129
expect(amadeus.shopping.flightDates.get).toBeDefined();
133130
expect(amadeus.shopping.flightDestinations.get).toBeDefined();
@@ -170,7 +167,7 @@ describe('Namespaces', () => {
170167
expect(amadeus.shopping.flightOffers.prediction.post).toBeDefined();
171168
expect(amadeus.booking.flightOrders.post).toBeDefined();
172169
expect(amadeus.shopping.flightOffersSearch.post).toBeDefined();
173-
expect(amadeus.travel.tripParserJobs('XXX').post).toBeDefined();
170+
expect(amadeus.travel.tripParser.post).toBeDefined();
174171
expect(amadeus.shopping.flightOffers.pricing.post).toBeDefined();
175172
expect(amadeus.shopping.seatmaps.post).toBeDefined();
176173
expect(amadeus.booking.hotelBookings.post).toBeDefined();
@@ -313,25 +310,11 @@ describe('Namespaces', () => {
313310
.toHaveBeenCalledWith('/v1/travel/analytics/air-traffic/busiest-period', {});
314311
});
315312

316-
it('.amadeus.travel.tripParserJobs().get', () => {
317-
amadeus.client.get = jest.fn();
318-
amadeus.travel.tripParserJobs('XXX').get();
319-
expect(amadeus.client.get)
320-
.toHaveBeenCalledWith('/v2/travel/trip-parser-jobs/XXX');
321-
});
322-
323-
it('.amadeus.travel.tripParserJobs().result.get', () => {
324-
amadeus.client.get = jest.fn();
325-
amadeus.travel.tripParserJobs('XXX').result.get();
326-
expect(amadeus.client.get)
327-
.toHaveBeenCalledWith('/v2/travel/trip-parser-jobs/XXX/result');
328-
});
329-
330-
it('.amadeus.travel.tripParserJobs().post', () => {
313+
it('.amadeus.travel.tripParser.post', () => {
331314
amadeus.client.post = jest.fn();
332-
amadeus.travel.tripParserJobs().post();
315+
amadeus.travel.tripParser.post();
333316
expect(amadeus.client.post)
334-
.toHaveBeenCalledWith('/v2/travel/trip-parser-jobs', {});
317+
.toHaveBeenCalledWith('/v3/travel/trip-parser', {});
335318
});
336319

337320
it('.amadeus.shopping.flightDates.get', () => {

src/amadeus/namespaces/travel.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Analytics from './travel/analytics';
22
import Predictions from './travel/predictions';
3-
import TripParserJobs from './travel/trip_parser_jobs';
3+
import TripParser from './travel/trip_parser';
44

55
/**
66
* A namespaced client for the
7-
* `/v1/travel` & `/v2/travel` endpoints
7+
* `/v1/travel` & `/v2/travel` & `/v3/travel` endpoints
88
*
99
* Access via the {@link Amadeus} object
1010
*
@@ -16,18 +16,15 @@ import TripParserJobs from './travel/trip_parser_jobs';
1616
* @param {Client} client
1717
* @property {Analytics} analytics
1818
* @property {Predictions} predictions
19-
* @property {TripParserJobs} tripParserJobs
19+
* @property {TripParser} tripParser
2020
* @protected
2121
*/
2222
class Travel {
2323
constructor(client) {
2424
this.client = client;
2525
this.analytics = new Analytics(client);
2626
this.predictions = new Predictions(client);
27-
}
28-
29-
tripParserJobs (jobId) {
30-
return new TripParserJobs(this.client, jobId);
27+
this.tripParser = new TripParser(client);
3128
}
3229
}
3330

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v3/travel/trip-parser` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.tripParser;
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class TripParser {
15+
constructor(client) {
16+
this.client = client;
17+
}
18+
19+
/**
20+
* parse information from flight, hotel, rail, and rental car confirmation emails
21+
*
22+
* @param {Object} params
23+
* @return {Promise.<Response,ResponseError>} a Promise
24+
*
25+
* "How can I show travelers their full itinerary in one place?"
26+
*
27+
* ```js
28+
* amadeus.tripParser.post(body);
29+
* ```
30+
*/
31+
post(params = {}) {
32+
return this.client.post('/v3/travel/trip-parser', params);
33+
}
34+
}
35+
36+
export default TripParser;

src/amadeus/namespaces/travel/trip_parser_jobs.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/amadeus/namespaces/travel/trip_parser_jobs/result.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)