Skip to content

Commit 37b7f77

Browse files
BREAKING CHANGE: add response object emptiness check (#26)
Co-authored-by: ProcessOut Fountain <internal@processout.com> BREAKING CHANGE:
1 parent bf78df1 commit 37b7f77

28 files changed

+325
-199
lines changed

processout/activity.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,11 @@ def find(self, activity_id, options={}):
202202
return_values = []
203203

204204
body = response.body
205-
body = body["activity"]
205+
body = body.get("activity")
206206

207-
obj = processout.Activity(self._client)
208-
return_values.append(obj.fill_with_data(body))
207+
if body is not None:
208+
209+
obj = processout.Activity(self._client)
210+
return_values.append(obj.fill_with_data(body))
209211

210212
return return_values[0]

processout/addon.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,11 @@ def create(self, options={}):
347347
return_values = []
348348

349349
body = response.body
350-
body = body["addon"]
350+
body = body.get("addon")
351351

352-
return_values.append(self.fill_with_data(body))
352+
if body is not None:
353+
354+
return_values.append(self.fill_with_data(body))
353355

354356
return return_values[0]
355357

@@ -372,10 +374,12 @@ def find(self, subscription_id, addon_id, options={}):
372374
return_values = []
373375

374376
body = response.body
375-
body = body["addon"]
377+
body = body.get("addon")
378+
379+
if body is not None:
376380

377-
obj = processout.Addon(self._client)
378-
return_values.append(obj.fill_with_data(body))
381+
obj = processout.Addon(self._client)
382+
return_values.append(obj.fill_with_data(body))
379383

380384
return return_values[0]
381385

@@ -406,9 +410,11 @@ def save(self, options={}):
406410
return_values = []
407411

408412
body = response.body
409-
body = body["addon"]
413+
body = body.get("addon")
414+
415+
if body is not None:
410416

411-
return_values.append(self.fill_with_data(body))
417+
return_values.append(self.fill_with_data(body))
412418

413419
return return_values[0]
414420

processout/alternativemerchantcertificate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ def save(self, options={}):
6464
return_values = []
6565

6666
body = response.body
67-
body = body["alternative_merchant_certificate"]
68-
alternativeMerchantCertificate = processout.AlternativeMerchantCertificate(
69-
self._client)
70-
return_values.append(
71-
alternativeMerchantCertificate.fill_with_data(body))
67+
body = body.get("alternative_merchant_certificate")
68+
if body is not None:
69+
alternativeMerchantCertificate = processout.AlternativeMerchantCertificate(
70+
self._client)
71+
return_values.append(
72+
alternativeMerchantCertificate.fill_with_data(body))
7273

7374
return return_values[0]
7475

processout/applepayalternativemerchantcertificates.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ def fetch(self, options={}):
9494
return_values = []
9595

9696
body = response.body
97-
body = body["applepay_certificates"]
98-
applePayAlternativeMerchantCertificates = processout.ApplePayAlternativeMerchantCertificates(
99-
self._client)
100-
return_values.append(
101-
applePayAlternativeMerchantCertificates.fill_with_data(body))
97+
body = body.get("applepay_certificates")
98+
if body is not None:
99+
applePayAlternativeMerchantCertificates = processout.ApplePayAlternativeMerchantCertificates(
100+
self._client)
101+
return_values.append(
102+
applePayAlternativeMerchantCertificates.fill_with_data(body))
102103

103104
return return_values[0]

processout/balances.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ def find(self, token_id, options={}):
128128
return_values = []
129129

130130
body = response.body
131-
body = body["balances"]
132-
balances = processout.Balances(self._client)
133-
return_values.append(balances.fill_with_data(body))
131+
body = body.get("balances")
132+
if body is not None:
133+
balances = processout.Balances(self._client)
134+
return_values.append(balances.fill_with_data(body))
134135

135136
return return_values[0]

processout/card.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,12 @@ def find(self, card_id, options={}):
653653
return_values = []
654654

655655
body = response.body
656-
body = body["card"]
656+
body = body.get("card")
657657

658-
obj = processout.Card(self._client)
659-
return_values.append(obj.fill_with_data(body))
658+
if body is not None:
659+
660+
obj = processout.Card(self._client)
661+
return_values.append(obj.fill_with_data(body))
660662

661663
return return_values[0]
662664

processout/cardcreaterequest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,10 @@ def create(self, options={}):
379379
return_values = []
380380

381381
body = response.body
382-
body = body["card"]
382+
body = body.get("card")
383383

384-
return_values.append(self.fill_with_data(body))
384+
if body is not None:
385+
386+
return_values.append(self.fill_with_data(body))
385387

386388
return return_values[0]

processout/cardinformation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ def fetch(self, iin, options={}):
166166
return_values = []
167167

168168
body = response.body
169-
body = body["card_information"]
169+
body = body.get("card_information")
170170

171-
obj = processout.CardInformation(self._client)
172-
return_values.append(obj.fill_with_data(body))
171+
if body is not None:
172+
173+
obj = processout.CardInformation(self._client)
174+
return_values.append(obj.fill_with_data(body))
173175

174176
return return_values[0]

processout/cardupdaterequest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def update(self, card_id, options={}):
6464
return_values = []
6565

6666
body = response.body
67-
body = body["card"]
67+
body = body.get("card")
6868

69-
return_values.append(self.fill_with_data(body))
69+
if body is not None:
70+
71+
return_values.append(self.fill_with_data(body))
7072

7173
return return_values[0]

processout/coupon.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,11 @@ def create(self, options={}):
311311
return_values = []
312312

313313
body = response.body
314-
body = body["coupon"]
314+
body = body.get("coupon")
315315

316-
return_values.append(self.fill_with_data(body))
316+
if body is not None:
317+
318+
return_values.append(self.fill_with_data(body))
317319

318320
return return_values[0]
319321

@@ -334,10 +336,12 @@ def find(self, coupon_id, options={}):
334336
return_values = []
335337

336338
body = response.body
337-
body = body["coupon"]
339+
body = body.get("coupon")
340+
341+
if body is not None:
338342

339-
obj = processout.Coupon(self._client)
340-
return_values.append(obj.fill_with_data(body))
343+
obj = processout.Coupon(self._client)
344+
return_values.append(obj.fill_with_data(body))
341345

342346
return return_values[0]
343347

@@ -358,9 +362,11 @@ def save(self, options={}):
358362
return_values = []
359363

360364
body = response.body
361-
body = body["coupon"]
365+
body = body.get("coupon")
366+
367+
if body is not None:
362368

363-
return_values.append(self.fill_with_data(body))
369+
return_values.append(self.fill_with_data(body))
364370

365371
return return_values[0]
366372

0 commit comments

Comments
 (0)