Skip to content

Commit efd724a

Browse files
author
Tom Hendrikx
committed
Ensure we handle resourcepaths with a querystring correctly
Without this change, we generated a broken querystring with two questionmarks.
1 parent 95be789 commit efd724a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

mollie/api/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ def _format_request_data(
181181

182182
querystring = generate_querystring(params)
183183
if querystring:
184-
url += "?" + querystring
184+
if "?" in url:
185+
# There is already a querystring in the URL
186+
url += "&" + querystring
187+
else:
188+
url += "?" + querystring
185189
params = None
186190

187191
return url, payload, params
@@ -204,7 +208,6 @@ def _perform_http_call_apikey(
204208

205209
url, payload, params = self._format_request_data(path, data, params)
206210
try:
207-
208211
headers = {
209212
"Accept": "application/json",
210213
"Authorization": f"Bearer {self.api_key}",
@@ -239,7 +242,6 @@ def _perform_http_call_oauth(
239242
) -> requests.Response:
240243
url, payload, params = self._format_request_data(path, data, params)
241244
try:
242-
243245
headers = {
244246
"Accept": "application/json",
245247
"Content-Type": "application/json",

tests/test_profile_chargebacks.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ def test_list_profile_chargebacks(oauth_client, response):
2121
assert chargebacks.has_next()
2222
more_chargebacks = chargebacks.get_next()
2323
assert_list_object(more_chargebacks, Chargeback)
24+
25+
26+
def test_list_profile_chargebacks_with_params(oauth_client, response):
27+
response.get(f"https://api.mollie.com/v2/profiles/{PROFILE_ID}", "profile_single")
28+
response.get(f"https://api.mollie.com/v2/chargebacks?profileId={PROFILE_ID}&limit=42", "profile_chargebacks_list")
29+
30+
profile = oauth_client.profiles.get(PROFILE_ID)
31+
profile.chargebacks.list(limit=42)

0 commit comments

Comments
 (0)