Skip to content

Commit 296ce80

Browse files
author
Jakub Reczko
committed
changed way of sending payload data for publication
1 parent 1c3c2c4 commit 296ce80

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

voucherify/client.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def __init__(self, application_id, client_secret_key):
2323
}
2424

2525
def request(self, path, method='GET', **kwargs):
26-
result = ""
27-
2826
try:
2927
url = ENDPOINT_URL + path
3028

@@ -35,8 +33,10 @@ def request(self, path, method='GET', **kwargs):
3533
timeout=self.timeout,
3634
**kwargs
3735
)
38-
except requests.ConnectionError or requests.HTTPError as e:
36+
except requests.HTTPError as e:
3937
response = json.loads(e.read())
38+
except requests.ConnectionError as e:
39+
raise VoucherifyError(e)
4040

4141
if response.headers.get('content-type') and 'json' in response.headers['content-type']:
4242
result = response.json()
@@ -138,13 +138,14 @@ def publish(self, campaign_name=""):
138138
path = '/vouchers/publish'
139139

140140
if campaign_name and isinstance(campaign_name, dict):
141-
path = path + '?' + urlencode(campaign_name)
141+
payload = campaign_name
142142
else:
143-
path = path + '?' + urlencode({'campaign': campaign_name})
143+
payload = {'campaign': campaign_name}
144144

145145
return self.request(
146146
path,
147-
method='POST'
147+
method='POST',
148+
data=json.dumps(payload)
148149
)
149150

150151

0 commit comments

Comments
 (0)