From e9e28240b851f2f8692aca4ec832923adcc2e267 Mon Sep 17 00:00:00 2001 From: Anna Tsolakou Date: Mon, 30 Sep 2024 11:56:25 +0200 Subject: [PATCH] decommission trip parser --- README.rst | 8 ------- amadeus/mixins/encoder.py | 7 ------ amadeus/namespaces/_travel.py | 11 ---------- amadeus/travel/__init__.py | 3 +-- amadeus/travel/_encoder.py | 19 ---------------- amadeus/travel/_trip_parser.py | 30 -------------------------- docs/index.rst | 6 ------ specs/mixins/encoder_specs_file.eml | 1 - specs/mixins/test_encoder.py | 31 --------------------------- specs/namespaces/test_namespaces.py | 29 ------------------------- specs/namespaces/trip_parser_test.eml | 1 - 11 files changed, 1 insertion(+), 145 deletions(-) delete mode 100644 amadeus/mixins/encoder.py delete mode 100644 amadeus/travel/_encoder.py delete mode 100644 amadeus/travel/_trip_parser.py delete mode 100644 specs/mixins/encoder_specs_file.eml delete mode 100644 specs/mixins/test_encoder.py delete mode 100644 specs/namespaces/trip_parser_test.eml diff --git a/README.rst b/README.rst index 0c1d78a6..a8b16b51 100644 --- a/README.rst +++ b/README.rst @@ -316,14 +316,6 @@ List of supported endpoints # Airport Routes amadeus.airport.direct_destinations.get(departureAirportCode='BLR') - # Trip Parser - # Encode to Base64 your booking confirmation file (.html, .eml, .pdf supported) - response = amadeus.travel.trip_parser.post(amadeus.travel.from_file(path_to_file)) - # Alternatively you can use a Base64 encoded content directly - response = amadeus.travel.trip_parser.post(amadeus.travel.from_base64(base64)) - # Or you can call the API with the JSON directly - response = amadeus.travel.trip_parser.post(body) - # Travel Recommendations amadeus.reference_data.recommended_locations.get(cityCodes='PAR', travelerCountryCode='FR') diff --git a/amadeus/mixins/encoder.py b/amadeus/mixins/encoder.py deleted file mode 100644 index 00bc71cf..00000000 --- a/amadeus/mixins/encoder.py +++ /dev/null @@ -1,7 +0,0 @@ -import base64 - - -# Encodes a file to Base64 format -def encode_file_to_base64(file): - with open(file, 'rb') as opened_file: - return base64.b64encode(opened_file.read()).decode() diff --git a/amadeus/namespaces/_travel.py b/amadeus/namespaces/_travel.py index 2d313dd9..906406f3 100644 --- a/amadeus/namespaces/_travel.py +++ b/amadeus/namespaces/_travel.py @@ -1,8 +1,6 @@ from amadeus.client.decorator import Decorator from amadeus.travel._analytics import Analytics from amadeus.travel._predictions import Predictions -from amadeus.travel._trip_parser import TripParser -from amadeus.travel._encoder import from_file, from_base64 class Travel(Decorator, object): @@ -10,12 +8,3 @@ def __init__(self, client): Decorator.__init__(self, client) self.analytics = Analytics(client) self.predictions = Predictions(client) - self.trip_parser = TripParser(client) - - @staticmethod - def from_file(file): - return from_file(file) - - @staticmethod - def from_base64(base64): - return from_base64(base64) diff --git a/amadeus/travel/__init__.py b/amadeus/travel/__init__.py index a59b8b70..083271e7 100644 --- a/amadeus/travel/__init__.py +++ b/amadeus/travel/__init__.py @@ -1,5 +1,4 @@ from ._analytics import Analytics from ._predictions import TripPurpose, FlightDelay -from ._trip_parser import TripParser -__all__ = ['Analytics', 'TripPurpose', 'FlightDelay', 'TripParser'] +__all__ = ['Analytics', 'TripPurpose', 'FlightDelay'] diff --git a/amadeus/travel/_encoder.py b/amadeus/travel/_encoder.py deleted file mode 100644 index 306e7c31..00000000 --- a/amadeus/travel/_encoder.py +++ /dev/null @@ -1,19 +0,0 @@ -from amadeus.mixins.encoder import encode_file_to_base64 - - -# Encodes file to Base64 and constructs POST body -def from_file(file): - encoded_file = encode_file_to_base64(file) - return __build_trip_parser_body(encoded_file) - - -# Constructs POST body from Base64 -def from_base64(base64): - return __build_trip_parser_body(base64) - - -# Takes a Base64 and returns a dict -def __build_trip_parser_body(base64): - return { - 'payload': base64, - } diff --git a/amadeus/travel/_trip_parser.py b/amadeus/travel/_trip_parser.py deleted file mode 100644 index d5cffacf..00000000 --- a/amadeus/travel/_trip_parser.py +++ /dev/null @@ -1,30 +0,0 @@ -from amadeus.client.decorator import Decorator - - -class TripParser(Decorator, object): - def __init__(self, client): - Decorator.__init__(self, client) - - def post(self, body): - ''' - Sends the request for the parsing with the - booking details and input parameters. - - .. code-block:: python - - amadeus.travel.trip_parser.post( - '{ - "payload": "base64string" - }' - - You can call our helper functions with your booking details - in a file or the content encoded in Base64 - - .. code-block:: python - amadeus.travel.trip_parser.post(amadeus.travel.from_file(path_to_file)) - amadeus.travel.trip_parser.post(amadeus.travel.from_base64(base64)) - - :rtype: amadeus.Response - :raises amadeus.ResponseError: if the request could not be completed - ''' - return self.client.post('/v3/travel/trip-parser', body) diff --git a/docs/index.rst b/docs/index.rst index 364cfa56..8eba14aa 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -113,12 +113,6 @@ Travel/Predictions .. autoclass:: amadeus.travel.predictions.FlightDelay :members: get -Travel/TripParser -================ - -.. autoclass:: amadeus.travel.TripParser - :members: post - ReferenceData/Locations ======================= diff --git a/specs/mixins/encoder_specs_file.eml b/specs/mixins/encoder_specs_file.eml deleted file mode 100644 index 9e9b0100..00000000 --- a/specs/mixins/encoder_specs_file.eml +++ /dev/null @@ -1 +0,0 @@ -booking \ No newline at end of file diff --git a/specs/mixins/test_encoder.py b/specs/mixins/test_encoder.py deleted file mode 100644 index d4463fa8..00000000 --- a/specs/mixins/test_encoder.py +++ /dev/null @@ -1,31 +0,0 @@ -import os -from amadeus.mixins.encoder import encode_file_to_base64 -from amadeus.travel._encoder import from_file, from_base64 - - -def test_file_encoding(): - file = str(os.path.dirname(os.path.abspath(__file__))) \ - + '/encoder_specs_file.eml' - base64 = 'Ym9va2luZw==' - result = encode_file_to_base64(file) - assert result == base64 - - -def test_from_file(): - file = str(os.path.dirname(os.path.abspath(__file__))) \ - + '/encoder_specs_file.eml' - base64 = 'Ym9va2luZw==' - body = { - 'payload': base64, - } - result = from_file(file) - assert result == body - - -def test_from_base64(): - base64 = 'Ym9va2luZw==' - body = { - 'payload': base64, - } - result = from_base64(base64) - assert result == body diff --git a/specs/namespaces/test_namespaces.py b/specs/namespaces/test_namespaces.py index 856a702f..ab215543 100644 --- a/specs/namespaces/test_namespaces.py +++ b/specs/namespaces/test_namespaces.py @@ -50,9 +50,6 @@ def test_expected_paths(client): assert client.airport.predictions is not None assert client.airport.predictions.on_time is not None assert client.airport.direct_destinations is not None - assert client.travel.trip_parser is not None - assert client.travel.from_file is not None - assert client.travel.from_base64 is not None assert client.booking.flight_orders is not None assert client.booking.flight_order is not None assert client.booking.hotel_orders is not None @@ -298,32 +295,6 @@ def test_shopping_flight_offers_prediction_post(client_setup): ) -def test_travel_trip_parser_post(client_setup): - client_setup.travel.trip_parser.post({'foo': 'bar'}) - client_setup.post.assert_called_with( - '/v3/travel/trip-parser', {'foo': 'bar'} - ) - - -def test_travel_trip_parser_post_from_base64(client_setup): - client_setup.travel.trip_parser.post( - client_setup.travel.from_base64('Qm9va2luZwo=')) - client_setup.post.assert_called_with( - '/v3/travel/trip-parser', - {'payload': 'Qm9va2luZwo='} - ) - - -def test_travel_trip_parser_post_from_file(client_setup): - file = 'specs/namespaces/trip_parser_test.eml' - client_setup.travel.trip_parser.post( - client_setup.travel.from_file(file)) - client_setup.post.assert_called_with( - '/v3/travel/trip-parser', - {'payload': 'Qm9va2luZwo='} - ) - - def test_shopping_flight_offers_search_post(client_setup): client_setup.shopping.flight_offers_search.post({'foo': 'bar'}) client_setup.post.assert_called_with( diff --git a/specs/namespaces/trip_parser_test.eml b/specs/namespaces/trip_parser_test.eml deleted file mode 100644 index b22111c9..00000000 --- a/specs/namespaces/trip_parser_test.eml +++ /dev/null @@ -1 +0,0 @@ -Booking