From 1bd0d05bf124793d727829b5a3bca929b4ec78e3 Mon Sep 17 00:00:00 2001 From: Siddhartha Dutta Date: Sat, 5 Feb 2022 11:58:44 +0530 Subject: [PATCH 1/2] add support for travel restrictions API --- README.rst | 3 +++ amadeus/namespaces/_travel_restrictions.py | 8 +++++++ amadeus/namespaces/core.py | 2 ++ amadeus/travel_restrictions/__init__.py | 3 +++ .../_covid19_area_report.py | 22 +++++++++++++++++++ docs/index.rst | 8 ++++++- specs/namespaces/namespaces_spec.py | 11 ++++++++++ 7 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 amadeus/namespaces/_travel_restrictions.py create mode 100644 amadeus/travel_restrictions/__init__.py create mode 100644 amadeus/travel_restrictions/_covid19_area_report.py diff --git a/README.rst b/README.rst index 97cca7b5..93a09740 100644 --- a/README.rst +++ b/README.rst @@ -336,6 +336,9 @@ List of supported endpoints amadeus.analytics.itinerary_price_metrics.get(originIataCode='MAD', destinationIataCode='CDG', departureDate='2021-03-21') + # Travel Restrictions + amadeus.travel_restrictions.covid19_area_report.get(countryCode="US") + Development & Contributing -------------------------- diff --git a/amadeus/namespaces/_travel_restrictions.py b/amadeus/namespaces/_travel_restrictions.py new file mode 100644 index 00000000..3685971d --- /dev/null +++ b/amadeus/namespaces/_travel_restrictions.py @@ -0,0 +1,8 @@ +from amadeus.client.decorator import Decorator +from amadeus.travel_restrictions import Covid19AreaReport + + +class TravelRestrictions(Decorator, object): + def __init__(self, client): + Decorator.__init__(self, client) + self.covid19_area_report = Covid19AreaReport(client) diff --git a/amadeus/namespaces/core.py b/amadeus/namespaces/core.py index 4e816e77..40721c13 100644 --- a/amadeus/namespaces/core.py +++ b/amadeus/namespaces/core.py @@ -9,6 +9,7 @@ from amadeus.namespaces._schedule import Schedule from amadeus.namespaces._analytics import Analytics from amadeus.namespaces._location import Location +from amadeus.namespaces._travel_restrictions import TravelRestrictions class Core(object): @@ -24,3 +25,4 @@ def __init__(self): self.schedule = Schedule(self) self.analytics = Analytics(self) self.location = Location(self) + self.travel_restrictions = TravelRestrictions(self) diff --git a/amadeus/travel_restrictions/__init__.py b/amadeus/travel_restrictions/__init__.py new file mode 100644 index 00000000..c8c7d55e --- /dev/null +++ b/amadeus/travel_restrictions/__init__.py @@ -0,0 +1,3 @@ +from ._covid19_area_report import Covid19AreaReport + +__all__ = ['Covid19AreaReport'] diff --git a/amadeus/travel_restrictions/_covid19_area_report.py b/amadeus/travel_restrictions/_covid19_area_report.py new file mode 100644 index 00000000..b482bcc6 --- /dev/null +++ b/amadeus/travel_restrictions/_covid19_area_report.py @@ -0,0 +1,22 @@ +from amadeus.client.decorator import Decorator + + +class Covid19AreaReport(Decorator, object): + def get(self, **params): + ''' + Returns the Covid-19 restrictions on targerted area. + + .. code-block:: python + + amadeus.travel_restrictions.covid19_area_report.get( + countryCode='US' + ) + + :param countryCode: ISO 3166 Alphas-2 code, for + example ``"US"`` for United States of America + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.get( + '/v1/duty-of-care/diseases/covid19-area-report', **params) diff --git a/docs/index.rst b/docs/index.rst index bbc560fe..eeacd662 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -221,4 +221,10 @@ Location/Analytics ================ .. autoclass:: amadeus.location.analytics.CategoryRatedAreas - :members: get \ No newline at end of file + :members: get + +TravelRestrictions/Covid19AreaReport +================ + +.. autoclass:: amadeus.travel_restrictions.Covid19AreaReport + :members: get diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index e0e27100..4d779f5e 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -87,6 +87,9 @@ expect(client.location).not_to(be_none) expect(client.location.analytics.category_rated_areas).not_to(be_none) + expect(client.travel_restrictions).not_to(be_none) + expect(client.travel_restrictions.covid19_area_report).not_to(be_none) + with it('should define all expected .get methods'): client = self.client expect(client.reference_data.urls.checkin_links.get).not_to(be_none) @@ -144,6 +147,8 @@ expect(client.location.analytics.category_rated_areas.get).not_to(be_none) + expect(client.travel_restrictions.covid19_area_report.get).not_to(be_none) + with it('should define all expected .delete methods'): client = self.client expect(client.booking.flight_order('123').delete).not_to(be_none) @@ -498,3 +503,9 @@ expect(self.client.get).to(have_been_called_with( '/v1/analytics/itinerary-price-metrics', a='b' )) + + with it('.travel_restrictions.covid19_area_report.get'): + self.client.travel_restrictions.covid19_area_report.get(a='b') + expect(self.client.get).to(have_been_called_with( + '/v1/duty-of-care/diseases/covid19-area-report', a='b' + )) From a10d50d69d4ace2cb40ac0d5ad3cf0547fcba915 Mon Sep 17 00:00:00 2001 From: Siddhartha Dutta Date: Fri, 11 Feb 2022 20:14:50 +0530 Subject: [PATCH 2/2] correct API path mapping --- README.rst | 4 ++-- amadeus/duty_of_care/__init__.py | 3 +++ .../_diseases.py} | 4 ++-- .../diseases}/__init__.py | 0 .../diseases}/_covid19_area_report.py | 0 amadeus/namespaces/_duty_of_care.py | 8 ++++++++ amadeus/namespaces/core.py | 4 ++-- docs/index.rst | 4 ++-- specs/namespaces/namespaces_spec.py | 11 ++++++----- 9 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 amadeus/duty_of_care/__init__.py rename amadeus/{namespaces/_travel_restrictions.py => duty_of_care/_diseases.py} (63%) rename amadeus/{travel_restrictions => duty_of_care/diseases}/__init__.py (100%) rename amadeus/{travel_restrictions => duty_of_care/diseases}/_covid19_area_report.py (100%) create mode 100644 amadeus/namespaces/_duty_of_care.py diff --git a/README.rst b/README.rst index 93a09740..a8d57ec2 100644 --- a/README.rst +++ b/README.rst @@ -336,8 +336,8 @@ List of supported endpoints amadeus.analytics.itinerary_price_metrics.get(originIataCode='MAD', destinationIataCode='CDG', departureDate='2021-03-21') - # Travel Restrictions - amadeus.travel_restrictions.covid19_area_report.get(countryCode="US") + # Covid-19 Area Report + amadeus.duty_of_care.diseases.covid19_area_report.get(countryCode="US") Development & Contributing -------------------------- diff --git a/amadeus/duty_of_care/__init__.py b/amadeus/duty_of_care/__init__.py new file mode 100644 index 00000000..e4c46a98 --- /dev/null +++ b/amadeus/duty_of_care/__init__.py @@ -0,0 +1,3 @@ +from ._diseases import Diseases + +__all__ = ['Diseases'] diff --git a/amadeus/namespaces/_travel_restrictions.py b/amadeus/duty_of_care/_diseases.py similarity index 63% rename from amadeus/namespaces/_travel_restrictions.py rename to amadeus/duty_of_care/_diseases.py index 3685971d..eed22efc 100644 --- a/amadeus/namespaces/_travel_restrictions.py +++ b/amadeus/duty_of_care/_diseases.py @@ -1,8 +1,8 @@ from amadeus.client.decorator import Decorator -from amadeus.travel_restrictions import Covid19AreaReport +from amadeus.duty_of_care.diseases import Covid19AreaReport -class TravelRestrictions(Decorator, object): +class Diseases(Decorator, object): def __init__(self, client): Decorator.__init__(self, client) self.covid19_area_report = Covid19AreaReport(client) diff --git a/amadeus/travel_restrictions/__init__.py b/amadeus/duty_of_care/diseases/__init__.py similarity index 100% rename from amadeus/travel_restrictions/__init__.py rename to amadeus/duty_of_care/diseases/__init__.py diff --git a/amadeus/travel_restrictions/_covid19_area_report.py b/amadeus/duty_of_care/diseases/_covid19_area_report.py similarity index 100% rename from amadeus/travel_restrictions/_covid19_area_report.py rename to amadeus/duty_of_care/diseases/_covid19_area_report.py diff --git a/amadeus/namespaces/_duty_of_care.py b/amadeus/namespaces/_duty_of_care.py new file mode 100644 index 00000000..49a5d8b2 --- /dev/null +++ b/amadeus/namespaces/_duty_of_care.py @@ -0,0 +1,8 @@ +from amadeus.client.decorator import Decorator +from amadeus.duty_of_care._diseases import Diseases + + +class DutyOfCare(Decorator, object): + def __init__(self, client): + Decorator.__init__(self, client) + self.diseases = Diseases(client) diff --git a/amadeus/namespaces/core.py b/amadeus/namespaces/core.py index 40721c13..e8af9793 100644 --- a/amadeus/namespaces/core.py +++ b/amadeus/namespaces/core.py @@ -9,7 +9,7 @@ from amadeus.namespaces._schedule import Schedule from amadeus.namespaces._analytics import Analytics from amadeus.namespaces._location import Location -from amadeus.namespaces._travel_restrictions import TravelRestrictions +from amadeus.namespaces._duty_of_care import DutyOfCare class Core(object): @@ -25,4 +25,4 @@ def __init__(self): self.schedule = Schedule(self) self.analytics = Analytics(self) self.location = Location(self) - self.travel_restrictions = TravelRestrictions(self) + self.duty_of_care = DutyOfCare(self) diff --git a/docs/index.rst b/docs/index.rst index eeacd662..8141d8e1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -223,8 +223,8 @@ Location/Analytics .. autoclass:: amadeus.location.analytics.CategoryRatedAreas :members: get -TravelRestrictions/Covid19AreaReport +DutyOfCare/Diseases ================ -.. autoclass:: amadeus.travel_restrictions.Covid19AreaReport +.. autoclass:: amadeus.duty_of_care.diseases.Covid19AreaReport :members: get diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 4d779f5e..7f8bb8b6 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -87,8 +87,8 @@ expect(client.location).not_to(be_none) expect(client.location.analytics.category_rated_areas).not_to(be_none) - expect(client.travel_restrictions).not_to(be_none) - expect(client.travel_restrictions.covid19_area_report).not_to(be_none) + expect(client.duty_of_care).not_to(be_none) + expect(client.duty_of_care.diseases.covid19_area_report).not_to(be_none) with it('should define all expected .get methods'): client = self.client @@ -147,7 +147,8 @@ expect(client.location.analytics.category_rated_areas.get).not_to(be_none) - expect(client.travel_restrictions.covid19_area_report.get).not_to(be_none) + expect(client.duty_of_care.diseases.covid19_area_report.get).not_to( + be_none) with it('should define all expected .delete methods'): client = self.client @@ -504,8 +505,8 @@ '/v1/analytics/itinerary-price-metrics', a='b' )) - with it('.travel_restrictions.covid19_area_report.get'): - self.client.travel_restrictions.covid19_area_report.get(a='b') + with it('.duty_of_care.diseases.covid19_area_report.get'): + self.client.duty_of_care.diseases.covid19_area_report.get(a='b') expect(self.client.get).to(have_been_called_with( '/v1/duty-of-care/diseases/covid19-area-report', a='b' ))