Skip to content

Commit 738cc8b

Browse files
author
Anthony Roux
committed
Merge branch 'hotel_v2' of https://github.com/anthonyroux/amadeus-python into hotel_v2
2 parents 319c1c3 + 555fcb8 commit 738cc8b

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

.github/CONTRIBUTING.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@ git clone https://github.com/amadeus4dev/amadeus-python.git
66
cd amadeus-python
77
```
88

9-
First, ensure you have a version of every Python we support installed. Your versions may differ.
9+
First, make sure your pyenv is initialized for each environment (`pyenv init `).
10+
If you want to have it loaded automatically, add the following to ~/.zshrc:
11+
12+
```sh
13+
eval "$(pyenv init -)"
14+
```
15+
16+
Second, ensure you have a version of every Python we support installed. Your versions may differ.
1017

1118
```sh
1219
pyenv install 2.7.14
1320
pyenv install 3.3.7
14-
pyenv install ...
15-
pyenv global 3.6.3 3.5.4 3.4.7 3.3.7 2.7.14
21+
pyenv install 3.4.9
22+
pyenv install 3.5.6
23+
pyenv install 3.6.3
24+
pyenv install 3.6.8
25+
pyenv global 3.6.8 3.6.3 3.5.6 3.4.9 3.3.7 2.7.14
1626
```
1727

1828
Next ensure you create a virtual environment.

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
2.0.1 - 2019-01-17
5+
--------------------
6+
7+
Fix pagination URL encoding parameters
8+
49
2.0.0 - 2018-10-14
510
--------------------
611

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ List of supported endpoints
220220
# Get a specific city or airport based on its id
221221
amadeus.reference_data.location('ALHR').get()
222222
223-
# Airport Nearest Relevant Airport
224-
amadeus.reference_data.locations.airports.get(longitude=49.000, latitude=2.55)
223+
# Airport Nearest Relevant Airport (for London)
224+
amadeus.reference_data.locations.airports.get(longitude=0.1278, latitude=51.5074)
225225
226226
# Flight Most Searched Destinations
227227
# Which were the most searched flight destinations from Madrid in August 2017?

amadeus/client/request.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __request_for_verb(self):
112112

113113
# Encodes the params before sending them
114114
def _encoded_params(self):
115-
return urlencode(self.params)
115+
return self._urlencode(self.params)
116116

117117
# Builds up the full URL based on the scheme, host, path, and params
118118
def __full_url(self):
@@ -141,3 +141,20 @@ def __add_bearer_token_header(self):
141141
# Applies all the headers to the HTTP Request object
142142
def __apply_headers(self, http_request):
143143
http_request.headers = self.headers
144+
145+
# Helper method to prepare the parameter encoding
146+
def _urlencode(self, d):
147+
return urlencode(self._flatten_keys(d, '', {}))
148+
149+
# Flattens the hash keys, so page: { offset: 1 } becomes page[offet] = 1
150+
def _flatten_keys(self, d, key, out):
151+
if type(d) is not dict:
152+
raise TypeError('Only dicts can be encoded')
153+
154+
for k in d:
155+
keystr = k if not key else '[{}]'.format(k)
156+
if type(d[k]) is dict:
157+
self._flatten_keys(d[k], str(key) + str(keystr), out)
158+
else:
159+
out['{}{}'.format(key, keystr)] = d[k]
160+
return out

amadeus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (2, 0, 0)
1+
version_info = (2, 0, 1)
22
version = '.'.join(str(v) for v in version_info)

0 commit comments

Comments
 (0)