Skip to content

Commit 135edf2

Browse files
sprutnertsolakoua
andauthored
Sprutner/add seatmap explorer (#60)
* 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 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 * added tests for seatmap adds basic tests for both the get and post functions for seatmap explorer * 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. * added more tests added required tests on paths and .get methods * fixed docstring typo * 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 * added tests for seatmap adds basic tests for both the get and post functions for seatmap explorer * fix issues from github merge conflict tool * 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. Co-authored-by: Anna Tsolakou <[email protected]>
1 parent 4845a44 commit 135edf2

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

README.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,12 @@ List of supported endpoints
228228
# The flight ID comes from the Flight Create Orders (in test environment it's temporary)
229229
flight_booking = amadeus.booking.flight_orders.post(body).data
230230
amadeus.booking.flight_order(flight_booking['id']).get()
231-
231+
232+
# Flight SeatMap Display GET
233+
amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"})
234+
# Flight SeatMap Display POST
235+
amadeus.shopping.seatmaps.post(body)
236+
232237
# Flight Low-fare Search
233238
amadeus.shopping.flight_offers.get(origin='MAD', destination='NYC', departureDate='2020-06-01')
234239
@@ -259,7 +264,7 @@ List of supported endpoints
259264
260265
# Flight Busiest Travel Period
261266
amadeus.travel.analytics.air_traffic.busiest_period.get(cityCode='MAD', period='2017', direction='ARRIVING')
262-
267+
263268
# Hotel Search
264269
# Get list of Hotels by city code
265270
amadeus.shopping.hotel_offers.get(cityCode = 'LON')
@@ -307,6 +312,11 @@ List of supported endpoints
307312
# Get the result of the process by jobId
308313
amadeus.travel.trip_parser_jobs.result(response.data['id']).get()
309314
315+
# Flight Offers Search GET
316+
amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2020-05-01', adults=1)
317+
# Flight Offers Search POST
318+
amadeus.shopping.flight_offers_search.post(body)
319+
310320
Development & Contributing
311321
--------------------------
312322

amadeus/namespaces/_shopping.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from amadeus.shopping._hotel_offers import HotelOffers
77
from amadeus.shopping._hotel_offers_by_hotel import HotelOffersByHotel
88
from amadeus.shopping._hotel_offer import HotelOffer
9+
from amadeus.shopping._seatmaps import Seatmaps
910

1011

1112
class Shopping(Decorator, object):
@@ -17,6 +18,7 @@ def __init__(self, client):
1718
self.hotel_offers = HotelOffers(client)
1819
self.hotel_offers_by_hotel = HotelOffersByHotel(client)
1920
self.flight_offers_search = FlightOffersSearch(client)
21+
self.seatmaps = Seatmaps(client)
2022

2123
def hotel_offer(self, offer_id):
2224
return HotelOffer(self.client, offer_id)

amadeus/shopping/_seatmaps.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class Seatmaps(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Allows you to retrieve the seat map of one or several flights based
8+
on the flight-orderId returned from Flight Create Orders API Call.
9+
10+
.. code-block:: python
11+
12+
amadeus.shopping.seatmaps.get(
13+
flight-orderId='<order_id>'
14+
)
15+
16+
:param flight-orderId: identifier of the order.
17+
Either a flight offer or a flight order Id.
18+
19+
:rtype: amadeus.Response
20+
:raises amadeus.ResponseError: if the request could not be completed
21+
'''
22+
return self.client.get('/v1/shopping/seatmaps', **params)
23+
24+
def post(self, body):
25+
'''
26+
Allows you to retrieve the seat map of one or several flights.
27+
Take the body of a flight offer search or flight offer price
28+
and pass it in to this method to get a seatmap
29+
30+
.. code-block:: python
31+
32+
amadeus.shopping.seatmaps.post(body)
33+
34+
:param body: the parameters to send to the API
35+
36+
:rtype: amadeus.Response
37+
:raises amadeus.ResponseError: if the request could not be completed
38+
'''
39+
return self.client.post('/v1/shopping/seatmaps', body)

specs/namespaces/namespaces_spec.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
expect(client.shopping.flight_offers_search).not_to(be_none)
4747
expect(client.shopping.flight_offers.pricing).not_to(be_none)
4848

49+
expect(client.shopping.seatmaps).not_to(be_none)
50+
4951
expect(client.shopping.hotel_offers).not_to(be_none)
5052
expect(client.shopping.hotel_offer).not_to(be_none)
5153
expect(client.shopping.hotel_offers_by_hotel).not_to(be_none)
@@ -102,6 +104,8 @@
102104
expect(client.shopping.flight_offers.get).not_to(be_none)
103105
expect(client.shopping.flight_offers_search.get).not_to(be_none)
104106

107+
expect(client.shopping.seatmaps.get).not_to(be_none)
108+
105109
expect(client.shopping.hotel_offers.get).not_to(be_none)
106110
expect(client.shopping.hotel_offers_by_hotel.get).not_to(be_none)
107111
expect(client.shopping.hotel_offer('123').get).not_to(be_none)
@@ -256,6 +260,12 @@
256260
'/v2/shopping/hotel-offers/XXX', a='b'
257261
))
258262

263+
with it('.shopping.seatmaps.get'):
264+
self.client.shopping.seatmaps.get(**{'a': 'b'})
265+
expect(self.client.get).to(have_been_called_with(
266+
'/v1/shopping/seatmaps', a='b'
267+
))
268+
259269
with it('.e_reputation.hotel_sentiments.get'):
260270
self.client.e_reputation.hotel_sentiments.get(hotelIds='XKPARC12')
261271
expect(self.client.get).to(have_been_called_with(
@@ -304,6 +314,12 @@
304314
'/v2/shopping/flight-offers', {'foo': 'bar'}
305315
))
306316

317+
with it('.shopping.seatmaps.post'):
318+
self.client.shopping.seatmaps.post({'foo': 'bar'})
319+
expect(self.client.post).to(have_been_called_with(
320+
'/v1/shopping/seatmaps', {'foo': 'bar'}
321+
))
322+
307323
with it('.shopping.flight_offers.pricing.post'):
308324
self.client.shopping.flight_offers.pricing.post({'foo': 'bar'})
309325
expect(self.client.post).to(have_been_called_with(

0 commit comments

Comments
 (0)