Skip to content

Commit 4d3bebe

Browse files
authored
Low-fare Search deco and update Flight Choice Prediction v2 (#87)
* update classes & tests & examples * delete low-fare search example * update readme * update departure date in example
1 parent 837fd5a commit 4d3bebe

File tree

7 files changed

+17
-57
lines changed

7 files changed

+17
-57
lines changed

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ List of supported endpoints
242242
amadeus.shopping.seatmaps.post(body)
243243
244244
# Flight Choice Prediction
245-
body = amadeus.shopping.flight_offers.get(origin='MAD', destination='NYC', departureDate='2020-10-01').result
245+
body = amadeus.shopping.flight_offers_search.get(
246+
originLocationCode='MAD',
247+
destinationLocationCode='NYC',
248+
departureDate='2020-11-01',
249+
adults=1).result
246250
amadeus.shopping.flight_offers.prediction.post(body)
247251
248252
# Flight Checkin Links

amadeus/shopping/_flight_offers.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,3 @@ def __init__(self, client):
88
Decorator.__init__(self, client)
99
self.prediction = FlightChoicePrediction(client)
1010
self.pricing = FlightOffersPrice(client)
11-
12-
def get(self, **params):
13-
'''
14-
Find the cheapest bookable flights.
15-
16-
.. code-block:: python
17-
18-
amadeus.shopping.flight_offers.get(
19-
origin='MAD',
20-
destination='NYC',
21-
departureDate='2020-08-01'
22-
)
23-
24-
:param origin: the City/Airport IATA code from which the flight will
25-
depart. ``"MAD"``, for example for Madrid.
26-
27-
:param destination: the City/Airport IATA code to which the flight is
28-
going. ``"BOS"``, for example for Boston.
29-
30-
:param departureDate: the date on which to fly out, in `YYYY-MM-DD`
31-
format
32-
33-
:rtype: amadeus.Response
34-
:raises amadeus.ResponseError: if the request could not be completed
35-
'''
36-
return self.client.get('/v1/shopping/flight-offers', **params)

amadeus/shopping/flight_offers/_prediction.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ def post(self, body):
99
.. code-block:: python
1010
1111
amadeus.shopping.flight_offers.prediction.post(
12-
amadeus.shopping.flight_offers.get(origin='MAD',
13-
destination='NYC',
14-
departureDate='2020-08-01'
15-
).result
12+
amadeus.shopping.flight_offers_search.get(
13+
originLocationCode='SYD',
14+
destinationLocationCode='BKK',
15+
departureDate='2020-11-01',
16+
adults=1).result
1617
)
1718
1819
:rtype: amadeus.Response
1920
:raises amadeus.ResponseError: if the request could not be completed
2021
'''
21-
return self.client.post('/v1/shopping/flight-offers/prediction', body)
22+
return self.client.post('/v2/shopping/flight-offers/prediction', body)

docs/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ Shopping/Flights
4444
.. autoclass:: amadeus.shopping.FlightDates
4545
:members: get
4646

47-
.. autoclass:: amadeus.shopping.FlightOffers
48-
:members: get
49-
5047
.. autoclass:: amadeus.shopping.FlightOffersSearch
5148
:members: get
5249

examples/flight_choice_prediction/flight_choice_prediction.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
'''
77
Find the probability of the flight MAD to NYC to be chosen
88
'''
9-
result = amadeus.shopping.flight_offers.get(origin='MAD', destination='NYC',
10-
departureDate='2020-10-01').result
9+
result = amadeus.shopping.flight_offers_search.get(
10+
originLocationCode='MAD',
11+
destinationLocationCode='NYC',
12+
departureDate='2020-11-01',
13+
adults=1).result
1114
response = amadeus.shopping.flight_offers.prediction.post(result)
1215
# print(response.data)
1316
except ResponseError as error:

examples/flight_low_fare_search/flight_low_fare_search.py

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

specs/namespaces/namespaces_spec.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494

9595
expect(client.shopping.flight_dates.get).not_to(be_none)
9696
expect(client.shopping.flight_destinations.get).not_to(be_none)
97-
expect(client.shopping.flight_offers.get).not_to(be_none)
9897
expect(client.shopping.flight_offers_search.get).not_to(be_none)
9998

10099
expect(client.shopping.seatmaps.get).not_to(be_none)
@@ -221,12 +220,6 @@
221220
'/v1/shopping/flight-destinations', a='b'
222221
))
223222

224-
with it('.shopping.flight_offers.get'):
225-
self.client.shopping.flight_offers.get(a='b')
226-
expect(self.client.get).to(have_been_called_with(
227-
'/v1/shopping/flight-offers', a='b'
228-
))
229-
230223
with it('.shopping.flight_offers_search.get'):
231224
self.client.shopping.flight_offers_search.get(a='b')
232225
expect(self.client.get).to(have_been_called_with(
@@ -290,7 +283,7 @@
290283
with it('.shopping.flight_offers.prediction.post'):
291284
self.client.shopping.flight_offers.prediction.post({'foo': 'bar'})
292285
expect(self.client.post).to(have_been_called_with(
293-
'/v1/shopping/flight-offers/prediction', {'foo': 'bar'}
286+
'/v2/shopping/flight-offers/prediction', {'foo': 'bar'}
294287
))
295288

296289
with it('.travel.trip_parser_jobs.post'):

0 commit comments

Comments
 (0)