From eaab91afa8fa05f6b53395c7e0fa2c6f897b23d3 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Sun, 29 Dec 2019 14:59:43 -0800 Subject: [PATCH 01/10] Adds seatmap explorer to the python-sdk This adds functionality to the amadeus python SDK to allow use of the "SeatMap Display" API endpoint within the python SDK. --- amadeus/namespaces/_shopping.py | 2 ++ amadeus/shopping/_seatmaps.py | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 amadeus/shopping/_seatmaps.py diff --git a/amadeus/namespaces/_shopping.py b/amadeus/namespaces/_shopping.py index a3c47217..2650494c 100644 --- a/amadeus/namespaces/_shopping.py +++ b/amadeus/namespaces/_shopping.py @@ -6,6 +6,7 @@ from amadeus.shopping._hotel_offers import HotelOffers from amadeus.shopping._hotel_offers_by_hotel import HotelOffersByHotel from amadeus.shopping._hotel_offer import HotelOffer +from amadeus.shopping._seatmaps import Seatmaps class Shopping(Decorator, object): @@ -17,6 +18,7 @@ def __init__(self, client): self.hotel_offers = HotelOffers(client) self.hotel_offers_by_hotel = HotelOffersByHotel(client) self.flight_offers_search = FlightOffersSearch(client) + self.seatmaps = Seatmaps(client) def hotel_offer(self, offer_id): return HotelOffer(self.client, offer_id) diff --git a/amadeus/shopping/_seatmaps.py b/amadeus/shopping/_seatmaps.py new file mode 100644 index 00000000..68671f83 --- /dev/null +++ b/amadeus/shopping/_seatmaps.py @@ -0,0 +1,36 @@ +from amadeus.client.decorator import Decorator + + +class Seatmaps(Decorator, object): + def get(self, **params): + ''' + Allows you to retrieve the seat map of one or several flights. + + .. code-block:: python + + amadeus.shopping.seatmaps.get( + flight-orderId='1577655015934--776131526' + ) + + :param flight-orderId: identifier of the order. + Either a flight offer or a flight order Id. + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.get('/v1/shopping/seatmaps', **params) + + def post(self, body): + ''' + Allows you to retrieve the seat map of one or several flights. + + .. code-block:: python + + amadeus.shopping.seatmaps.post(body) + + :param body: the parameters to send to the API + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.post('/v2/shopping/flight-offers', body) From 15518429fe7f10c12dd5a108ff442a550af3f3f9 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Sun, 29 Dec 2019 14:59:43 -0800 Subject: [PATCH 02/10] Adds seatmap explorer to the python-sdk This adds functionality to the amadeus python SDK to allow use of the "SeatMap Display" API endpoint within the python SDK. Adds documentation and fixed URL --- README.rst | 5 +++++ amadeus/shopping/_seatmaps.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2d0a5d6c..81bf65cf 100644 --- a/README.rst +++ b/README.rst @@ -296,6 +296,11 @@ List of supported endpoints # Flight Offers Search POST amadeus.shopping.flight_offers_search.post(body) + # SeatMap Display GET + amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"}) + # SeatMap Display POST + amadeus.shopping.seatmaps.post(body) + Development & Contributing -------------------------- diff --git a/amadeus/shopping/_seatmaps.py b/amadeus/shopping/_seatmaps.py index 68671f83..0c4080c7 100644 --- a/amadeus/shopping/_seatmaps.py +++ b/amadeus/shopping/_seatmaps.py @@ -33,4 +33,4 @@ def post(self, body): :rtype: amadeus.Response :raises amadeus.ResponseError: if the request could not be completed ''' - return self.client.post('/v2/shopping/flight-offers', body) + return self.client.post('/v1/shopping/seatmaps', body) From 8b24a0bcd974f01ea56a41304b9a852a86e54da6 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Wed, 29 Jan 2020 13:28:37 -0800 Subject: [PATCH 03/10] added tests for seatmap adds basic tests for both the get and post functions for seatmap explorer --- specs/namespaces/namespaces_spec.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 5a1405cc..2d2c7349 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -250,6 +250,12 @@ '/v2/shopping/hotel-offers/XXX', a='b' )) + with it('.shopping.seatmaps.get'): + self.client.shopping.seatmaps.get(a='b') + expect(self.client.get).to(have_been_called_with( + '/v1/shopping/seatmaps', a='b' + )) + with it('.e_reputation.hotel_sentiments.get'): self.client.e_reputation.hotel_sentiments.get(hotelIds='XKPARC12') expect(self.client.get).to(have_been_called_with( @@ -297,3 +303,9 @@ expect(self.client.post).to(have_been_called_with( '/v2/shopping/flight-offers', {'foo': 'bar'} )) + + with it('.shopping.seatmaps.post'): + self.client.shopping.seatmaps.post({'foo': 'bar'}) + expect(self.client.post).to(have_been_called_with( + '/v1/shopping/seatmaps', {'foo': 'bar'} + )) From 6a37063fd7248514adb0d5bd34549378cb0115e4 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Wed, 29 Jan 2020 13:31:50 -0800 Subject: [PATCH 04/10] updated docs on seatmap explorer made the documentation more specific, and removed the invalid offerid, as the get method only supports order id from flights that have already been ordered. --- amadeus/shopping/_seatmaps.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amadeus/shopping/_seatmaps.py b/amadeus/shopping/_seatmaps.py index 0c4080c7..7e674181 100644 --- a/amadeus/shopping/_seatmaps.py +++ b/amadeus/shopping/_seatmaps.py @@ -4,12 +4,13 @@ class Seatmaps(Decorator, object): def get(self, **params): ''' - Allows you to retrieve the seat map of one or several flights. + Allows you to retrieve the seat map of one or several flights based + on the flight-orderId returned from Flight Create Orders API Call. .. code-block:: python amadeus.shopping.seatmaps.get( - flight-orderId='1577655015934--776131526' + flight-orderId='' ) :param flight-orderId: identifier of the order. @@ -23,6 +24,8 @@ def get(self, **params): def post(self, body): ''' Allows you to retrieve the seat map of one or several flights. + Take the body of a flight offer search or flight offer search + and pass it in to this method to get a seatmap .. code-block:: python From 1ec48bacd69b285d5681640e131701592abada01 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Fri, 31 Jan 2020 15:00:56 -0800 Subject: [PATCH 05/10] added more tests added required tests on paths and .get methods --- specs/namespaces/namespaces_spec.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 2d2c7349..d5792418 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -45,6 +45,8 @@ expect(client.shopping.flight_offers).not_to(be_none) expect(client.shopping.flight_offers_search).not_to(be_none) + expect(client.shopping.seatmaps).not_to(be_none) + expect(client.shopping.hotel_offers).not_to(be_none) expect(client.shopping.hotel_offer).not_to(be_none) expect(client.shopping.hotel_offers_by_hotel).not_to(be_none) @@ -98,6 +100,8 @@ expect(client.shopping.flight_offers.get).not_to(be_none) expect(client.shopping.flight_offers_search.get).not_to(be_none) + expect(client.shopping.seatmaps.get).not_to(be_none) + expect(client.shopping.hotel_offers.get).not_to(be_none) expect(client.shopping.hotel_offers_by_hotel.get).not_to(be_none) expect(client.shopping.hotel_offer('123').get).not_to(be_none) From 3a750294dbc2c250a1be5257bb42dbade4c0d9c4 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Fri, 31 Jan 2020 15:02:24 -0800 Subject: [PATCH 06/10] fixed docstring typo --- amadeus/shopping/_seatmaps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amadeus/shopping/_seatmaps.py b/amadeus/shopping/_seatmaps.py index 7e674181..19c5d858 100644 --- a/amadeus/shopping/_seatmaps.py +++ b/amadeus/shopping/_seatmaps.py @@ -24,7 +24,7 @@ def get(self, **params): def post(self, body): ''' Allows you to retrieve the seat map of one or several flights. - Take the body of a flight offer search or flight offer search + Take the body of a flight offer search or flight offer price and pass it in to this method to get a seatmap .. code-block:: python From e216d9504a1dd2ec46b71b39f160e373138d6b65 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Sun, 29 Dec 2019 14:59:43 -0800 Subject: [PATCH 07/10] Adds seatmap explorer to the python-sdk This adds functionality to the amadeus python SDK to allow use of the "SeatMap Display" API endpoint within the python SDK. Adds documentation and fixed URL --- README.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 8d8af22d..5e92a9e3 100644 --- a/README.rst +++ b/README.rst @@ -228,7 +228,7 @@ List of supported endpoints # The flight ID comes from the Flight Create Orders (in test environment it's temporary) flight_booking = amadeus.booking.flight_orders.post(body).data amadeus.booking.flight_order(flight_booking['id']).get() - + # Flight Low-fare Search amadeus.shopping.flight_offers.get(origin='MAD', destination='NYC', departureDate='2020-06-01') @@ -312,6 +312,16 @@ List of supported endpoints # Get the result of the process by jobId amadeus.travel.trip_parser_jobs.result(response.data['id']).get() + # Flight Offers Search GET + amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2020-05-01', adults=1) + # Flight Offers Search POST + amadeus.shopping.flight_offers_search.post(body) + + # SeatMap Display GET + amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"}) + # SeatMap Display POST + amadeus.shopping.seatmaps.post(body) + Development & Contributing -------------------------- From 8f2841125a36d5ccb26298251abe208167635353 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Wed, 29 Jan 2020 13:28:37 -0800 Subject: [PATCH 08/10] added tests for seatmap adds basic tests for both the get and post functions for seatmap explorer --- specs/namespaces/namespaces_spec.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 3f8c4b2e..226db85b 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -354,3 +354,9 @@ 'payments': [{'bar': 'foo'}] }} )) + + with it('.shopping.seatmaps.post'): + self.client.shopping.seatmaps.post({'foo': 'bar'}) + expect(self.client.post).to(have_been_called_with( + '/v1/shopping/seatmaps', {'foo': 'bar'} + )) From b6092a77a130a470be5f31e0b36f0d85051bfeb0 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Mon, 3 Feb 2020 11:26:39 -0800 Subject: [PATCH 09/10] fix issues from github merge conflict tool --- specs/namespaces/namespaces_spec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 226db85b..c790de22 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -318,7 +318,8 @@ self.client.shopping.seatmaps.post({'foo': 'bar'}) expect(self.client.post).to(have_been_called_with( '/v1/shopping/seatmaps', {'foo': 'bar'} - + )) + with it('.shopping.flight_offers.pricing.post'): self.client.shopping.flight_offers.pricing.post({'foo': 'bar'}) expect(self.client.post).to(have_been_called_with( From 5c540903f4199191aeab898de32bbfd3ba0dd1d2 Mon Sep 17 00:00:00 2001 From: Seth Rutner Date: Tue, 11 Feb 2020 13:03:55 -0800 Subject: [PATCH 10/10] removed duplicate readme entries, tests, rewrote test case this removes a duplicate readme entry. This also renames the readme entry to be flight seatmaps instead of just seatmaps to fit more with the style of the readme the testcase for seatmaps.get was changed to pass in the args in the style that is also used in the readme. the reason the args are passed in like this is because there is a hyphen present in the arg name. this also removes a duplicate post test. --- README.rst | 15 +++++---------- specs/namespaces/namespaces_spec.py | 8 +------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/README.rst b/README.rst index 5e92a9e3..32c8a55f 100644 --- a/README.rst +++ b/README.rst @@ -229,6 +229,11 @@ List of supported endpoints flight_booking = amadeus.booking.flight_orders.post(body).data amadeus.booking.flight_order(flight_booking['id']).get() + # Flight SeatMap Display GET + amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"}) + # Flight SeatMap Display POST + amadeus.shopping.seatmaps.post(body) + # Flight Low-fare Search amadeus.shopping.flight_offers.get(origin='MAD', destination='NYC', departureDate='2020-06-01') @@ -259,11 +264,6 @@ List of supported endpoints # Flight Busiest Travel Period amadeus.travel.analytics.air_traffic.busiest_period.get(cityCode='MAD', period='2017', direction='ARRIVING') - - # SeatMap Display GET - amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"}) - # SeatMap Display POST - amadeus.shopping.seatmaps.post(body) # Hotel Search # Get list of Hotels by city code @@ -317,11 +317,6 @@ List of supported endpoints # Flight Offers Search POST amadeus.shopping.flight_offers_search.post(body) - # SeatMap Display GET - amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"}) - # SeatMap Display POST - amadeus.shopping.seatmaps.post(body) - Development & Contributing -------------------------- diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index c790de22..5592d4bd 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -261,7 +261,7 @@ )) with it('.shopping.seatmaps.get'): - self.client.shopping.seatmaps.get(a='b') + self.client.shopping.seatmaps.get(**{'a': 'b'}) expect(self.client.get).to(have_been_called_with( '/v1/shopping/seatmaps', a='b' )) @@ -355,9 +355,3 @@ 'payments': [{'bar': 'foo'}] }} )) - - with it('.shopping.seatmaps.post'): - self.client.shopping.seatmaps.post({'foo': 'bar'}) - expect(self.client.post).to(have_been_called_with( - '/v1/shopping/seatmaps', {'foo': 'bar'} - ))