Skip to content

Commit d89344c

Browse files
Merge pull request #95 from Adyen/develop
Merge to master
2 parents ce3dff7 + 96ae5a2 commit d89344c

File tree

17 files changed

+237
-247
lines changed

17 files changed

+237
-247
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Aleffio @AlexandrosMor @martinsrenato @KadoBOT @rikterbeek

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*.pypirc
55
releaseguide.md
66
venv/
7-
.idea/
7+
.idea/
8+
.coverage

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ python:
44
- "2.7"
55
- "3.6"
66
cache: pip
7+
before_install:
8+
- sudo apt-get install libgnutls28-dev
79
install:
8-
- pip install requests pycurl mock coveralls pylint pycodestyle
10+
- make install
911
script:
10-
- coverage run -m unittest discover -s test -p '*Test.py'
12+
- make coverage
1113
- pycodestyle -v
1214
after_success:
1315
- coveralls

Adyen/client.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,17 @@ def call_api(self, request_data, service, action, idempotency=False,
303303

304304
url = self._determine_api_url(platform, service, action)
305305

306-
raw_response, raw_request, status_code, headers = \
307-
self.http_client.request(url, json=message, username=username,
308-
password=password, headers=headers,
309-
**kwargs)
306+
if xapikey:
307+
raw_response, raw_request, status_code, headers = \
308+
self.http_client.request(url, json=request_data,
309+
xapikey=xapikey, headers=headers,
310+
**kwargs)
311+
else:
312+
raw_response, raw_request, status_code, headers = \
313+
self.http_client.request(url, json=message, username=username,
314+
password=password,
315+
headers=headers,
316+
**kwargs)
310317

311318
# Creates AdyenResponse if request was successful, raises error if not.
312319
adyen_result = self._handle_response(url, raw_response, raw_request,

Adyen/httpclient.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _pycurl_post(self,
6161
username="",
6262
password="",
6363
xapikey="",
64-
headers={},
64+
headers=None,
6565
timeout=30):
6666
"""This function will POST to the url endpoint using pycurl. returning
6767
an AdyenResult object on 200 HTTP responce. Either json or data has to
@@ -89,6 +89,8 @@ def _pycurl_post(self,
8989
int: HTTP status code, eg 200,404,401
9090
dict: Key/Value pairs of the headers received.
9191
"""
92+
if headers is None:
93+
headers = {}
9294

9395
response_headers = {}
9496

@@ -148,7 +150,7 @@ def _requests_post(self, url,
148150
username="",
149151
password="",
150152
xapikey="",
151-
headers={},
153+
headers=None,
152154
timeout=30):
153155
"""This function will POST to the url endpoint using requests.
154156
Returning an AdyenResult object on 200 HTTP response.
@@ -176,6 +178,8 @@ def _requests_post(self, url,
176178
int: HTTP status code, eg 200,404,401
177179
dict: Key/Value pairs of the headers received.
178180
"""
181+
if headers is None:
182+
headers = {}
179183

180184
# Adding basic auth if username and password provided.
181185
auth = None
@@ -204,7 +208,7 @@ def _urllib_post(self, url,
204208
username="",
205209
password="",
206210
xapikey="",
207-
headers={},
211+
headers=None,
208212
timeout=30):
209213

210214
"""This function will POST to the url endpoint using urllib2. returning
@@ -234,6 +238,9 @@ def _urllib_post(self, url,
234238
dict: Key/Value pairs of the headers received.
235239
"""
236240

241+
if headers is None:
242+
headers = {}
243+
237244
# Store regular dict to return later:
238245
raw_store = json
239246

0 commit comments

Comments
 (0)