Skip to content

Commit e6b4ed9

Browse files
authored
Merge pull request #161 from amadeus4dev/update-trip-parser
Remove trip parser v2 and add v3
2 parents ee2792b + 7a61c21 commit e6b4ed9

File tree

11 files changed

+50
-139
lines changed

11 files changed

+50
-139
lines changed

amadeus/namespaces/_travel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from amadeus.client.decorator import Decorator
22
from amadeus.travel._analytics import Analytics
33
from amadeus.travel._predictions import Predictions
4-
from amadeus.travel._trip_parser_jobs import TripParser
4+
from amadeus.travel._trip_parser import TripParser
55
from amadeus.travel._encoder import from_file, from_base64
66

77

@@ -10,7 +10,7 @@ def __init__(self, client):
1010
Decorator.__init__(self, client)
1111
self.analytics = Analytics(client)
1212
self.predictions = Predictions(client)
13-
self.trip_parser_jobs = TripParser(client)
13+
self.trip_parser = TripParser(client)
1414

1515
def from_file(self, file):
1616
return from_file(file)

amadeus/travel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._analytics import Analytics
22
from ._predictions import TripPurpose, FlightDelay
3-
from ._trip_parser_jobs import TripParser
3+
from ._trip_parser import TripParser
44

55
__all__ = ['Analytics', 'TripPurpose', 'FlightDelay', 'TripParser']

amadeus/travel/_encoder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@ def from_base64(base64):
1515
# Takes a Base64 and returns a dict
1616
def __build_trip_parser_body(base64):
1717
return {
18-
'data': {
19-
'type': 'trip-parser-job',
20-
'content': base64,
21-
},
18+
'payload': base64,
2219
}

amadeus/travel/_trip_parser.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class TripParser(Decorator, object):
5+
def __init__(self, client):
6+
Decorator.__init__(self, client)
7+
8+
def post(self, body):
9+
'''
10+
Sends the request for the parsing with the
11+
booking details and input parameters.
12+
13+
.. code-block:: python
14+
15+
amadeus.travel.trip_parser.post(
16+
'{
17+
"payload": "base64string"
18+
}'
19+
20+
You can call our helper functions with your booking details
21+
in a file or the content encoded in Base64
22+
23+
.. code-block:: python
24+
amadeus.travel.trip_parser.post(amadeus.travel.from_file(path_to_file))
25+
amadeus.travel.trip_parser.post(amadeus.travel.from_base64(base64))
26+
27+
:rtype: amadeus.Response
28+
:raises amadeus.ResponseError: if the request could not be completed
29+
'''
30+
return self.client.post('/v3/travel/trip-parser', body)

amadeus/travel/_trip_parser_jobs.py

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

amadeus/travel/trip_parser_jobs/__init__.py

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

amadeus/travel/trip_parser_jobs/_result.py

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

amadeus/travel/trip_parser_jobs/_status.py

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

docs/index.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ Travel/TripParser
122122
.. autoclass:: amadeus.travel.TripParser
123123
:members: post
124124

125-
.. autoclass:: amadeus.travel.trip_parser_jobs.status.TripParserStatus
126-
:members: get
127-
128-
.. autoclass:: amadeus.travel.trip_parser_jobs.result.TripParserResult
129-
:members: get
130-
131125
ReferenceData/Locations
132126
=======================
133127

specs/mixins/encoder_spec.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,14 @@
1717
+ '/encoder_specs_file.eml'
1818
base64 = 'Ym9va2luZw=='
1919
body = {
20-
'data': {
21-
'type': 'trip-parser-job',
22-
'content': base64,
23-
},
20+
'payload': base64,
2421
}
2522
expect(from_file(file)).to(equal(body))
2623

2724
with description('Travel/From Base64'):
2825
with it('should generate the defined POST body from base64'):
2926
base64 = 'Ym9va2luZw=='
3027
body = {
31-
'data': {
32-
'type': 'trip-parser-job',
33-
'content': base64,
34-
},
28+
'payload': base64,
3529
}
3630
expect(from_base64(base64)).to(equal(body))

0 commit comments

Comments
 (0)