Skip to content

Commit 2dec6d4

Browse files
authored
Merge pull request #162 from amadeus4dev/travel-restrictions-v2
add travel restrictions v2
2 parents ab86a17 + 32e82ae commit 2dec6d4

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,15 @@ amadeus.analytics.itineraryPriceMetrics.get({
546546
// Travel Restrictions
547547
// The Travel Restrictions API provides up-to-date data on COVID-19 caseloads and travel restrictions for over 200 countries and territories,
548548
// as well as hundreds of cities and regions worldwide.
549+
550+
// Travel Restrictions API v2
551+
amadeus.dutyOfCare.diseases.covid19Report.get({
552+
countryCode: 'US',
553+
cityCode: 'NYC',
554+
language: 'EN'
555+
});
556+
557+
// Travel Restrictions API v1
549558
amadeus.dutyOfCare.diseases.covid19AreaReport.get({
550559
countryCode: 'US',
551560
cityCode: 'NYC'

spec/amadeus/namespaces.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe('Namespaces', () => {
102102
expect(amadeus.dutyOfCare).toBeDefined();
103103
expect(amadeus.dutyOfCare.diseases).toBeDefined();
104104
expect(amadeus.dutyOfCare.diseases.covid19AreaReport).toBeDefined();
105+
expect(amadeus.dutyOfCare.diseases.covid19Report).toBeDefined();
105106

106107
expect(amadeus.airline.destinations).toBeDefined();
107108
});
@@ -161,6 +162,7 @@ describe('Namespaces', () => {
161162
expect(amadeus.location.analytics.categoryRatedAreas.get).toBeDefined();
162163

163164
expect(amadeus.dutyOfCare.diseases.covid19AreaReport.get).toBeDefined();
165+
expect(amadeus.dutyOfCare.diseases.covid19Report.get).toBeDefined();
164166

165167
expect(amadeus.airline.destinations.get).toBeDefined();
166168
});
@@ -543,6 +545,13 @@ describe('Namespaces', () => {
543545
.toHaveBeenCalledWith('/v1/duty-of-care/diseases/covid19-area-report', {});
544546
});
545547

548+
it('.amadeus.dutyOfCare.diseases.covid19Report.get', () => {
549+
amadeus.client.get = jest.fn();
550+
amadeus.dutyOfCare.diseases.covid19Report.get();
551+
expect(amadeus.client.get)
552+
.toHaveBeenCalledWith('/v2/duty-of-care/diseases/covid19-area-report', {});
553+
});
554+
546555
it('.amadeus.airline.destinations.get', () => {
547556
amadeus.client.get = jest.fn();
548557
amadeus.airline.destinations.get();

src/amadeus/namespaces/duty_of_care/diseases.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Covid19AreaReport from './diseases/covid19_area_report';
2+
import Covid19Report from './diseases/covid19_report';
23
/**
34
* A namespaced client for the
4-
* `/v1/duty-of-care/diseases` endpoints
5+
* `/v1/duty-of-care/diseases` and `/v2/duty-of-care/diseases` endpoints
56
*
67
* Access via the {@link Amadeus} object
78
*
@@ -16,6 +17,7 @@ class Diseases {
1617
constructor(client) {
1718
this.client = client;
1819
this.covid19AreaReport = new Covid19AreaReport(client);
20+
this.covid19Report = new Covid19Report(client);
1921
}
2022
}
2123

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v2/duty-of-care/diseases/covid19-area-report` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.dutyOfCare.diseases.covid19Report;
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class Covid19Report {
15+
constructor(client) {
16+
this.client = client;
17+
}
18+
19+
/**
20+
* Returns Covid-19 related restrictions for a given country
21+
*
22+
* @param {Object} params
23+
* @param {string} params.countryCode ISO 3166 Alpha-2 code. e.g. "US" United States of America.
24+
* @return {Promise.<Response,ResponseError>} a Promise
25+
*
26+
* Returns Covid-19 restrictions in the United States
27+
*
28+
* ```js
29+
* amadeus.dutyOfCare.diseases.covid19Report.get({
30+
* countryCode: 'US'
31+
* }).then(function(response){
32+
* console.log(response.data);
33+
* }).catch(function(responseError){
34+
* console.log(responseError);
35+
* });
36+
* ```
37+
*/
38+
39+
40+
get(params = {}) {
41+
return this.client.get('/v2/duty-of-care/diseases/covid19-area-report', params);
42+
}
43+
}
44+
45+
export default Covid19Report;

0 commit comments

Comments
 (0)