diff --git a/processout/activity.py b/processout/activity.py index 998862a..71bb652 100755 --- a/processout/activity.py +++ b/processout/activity.py @@ -202,9 +202,11 @@ def find(self, activity_id, options={}): return_values = [] body = response.body - body = body["activity"] + body = body.get("activity") - obj = processout.Activity(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Activity(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/addon.py b/processout/addon.py index 10372b1..613b5d4 100755 --- a/processout/addon.py +++ b/processout/addon.py @@ -347,9 +347,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["addon"] + body = body.get("addon") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -372,10 +374,12 @@ def find(self, subscription_id, addon_id, options={}): return_values = [] body = response.body - body = body["addon"] + body = body.get("addon") + + if body is not None: - obj = processout.Addon(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Addon(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -406,9 +410,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["addon"] + body = body.get("addon") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/alternativemerchantcertificate.py b/processout/alternativemerchantcertificate.py index 4ae4350..31a5726 100755 --- a/processout/alternativemerchantcertificate.py +++ b/processout/alternativemerchantcertificate.py @@ -64,11 +64,12 @@ def save(self, options={}): return_values = [] body = response.body - body = body["alternative_merchant_certificate"] - alternativeMerchantCertificate = processout.AlternativeMerchantCertificate( - self._client) - return_values.append( - alternativeMerchantCertificate.fill_with_data(body)) + body = body.get("alternative_merchant_certificate") + if body is not None: + alternativeMerchantCertificate = processout.AlternativeMerchantCertificate( + self._client) + return_values.append( + alternativeMerchantCertificate.fill_with_data(body)) return return_values[0] diff --git a/processout/applepayalternativemerchantcertificates.py b/processout/applepayalternativemerchantcertificates.py index 70cbeca..9d5043a 100755 --- a/processout/applepayalternativemerchantcertificates.py +++ b/processout/applepayalternativemerchantcertificates.py @@ -94,10 +94,11 @@ def fetch(self, options={}): return_values = [] body = response.body - body = body["applepay_certificates"] - applePayAlternativeMerchantCertificates = processout.ApplePayAlternativeMerchantCertificates( - self._client) - return_values.append( - applePayAlternativeMerchantCertificates.fill_with_data(body)) + body = body.get("applepay_certificates") + if body is not None: + applePayAlternativeMerchantCertificates = processout.ApplePayAlternativeMerchantCertificates( + self._client) + return_values.append( + applePayAlternativeMerchantCertificates.fill_with_data(body)) return return_values[0] diff --git a/processout/balances.py b/processout/balances.py index 06b953d..eaceeec 100755 --- a/processout/balances.py +++ b/processout/balances.py @@ -128,8 +128,9 @@ def find(self, token_id, options={}): return_values = [] body = response.body - body = body["balances"] - balances = processout.Balances(self._client) - return_values.append(balances.fill_with_data(body)) + body = body.get("balances") + if body is not None: + balances = processout.Balances(self._client) + return_values.append(balances.fill_with_data(body)) return return_values[0] diff --git a/processout/card.py b/processout/card.py index 414b7f2..a5c465c 100755 --- a/processout/card.py +++ b/processout/card.py @@ -653,10 +653,12 @@ def find(self, card_id, options={}): return_values = [] body = response.body - body = body["card"] + body = body.get("card") - obj = processout.Card(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Card(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/cardcreaterequest.py b/processout/cardcreaterequest.py index 0328942..8aa4a05 100755 --- a/processout/cardcreaterequest.py +++ b/processout/cardcreaterequest.py @@ -379,8 +379,10 @@ def create(self, options={}): return_values = [] body = response.body - body = body["card"] + body = body.get("card") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/cardinformation.py b/processout/cardinformation.py index 0d66f92..ce5951e 100755 --- a/processout/cardinformation.py +++ b/processout/cardinformation.py @@ -166,9 +166,11 @@ def fetch(self, iin, options={}): return_values = [] body = response.body - body = body["card_information"] + body = body.get("card_information") - obj = processout.CardInformation(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.CardInformation(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/cardupdaterequest.py b/processout/cardupdaterequest.py index 94f6050..aa8f2ef 100755 --- a/processout/cardupdaterequest.py +++ b/processout/cardupdaterequest.py @@ -64,8 +64,10 @@ def update(self, card_id, options={}): return_values = [] body = response.body - body = body["card"] + body = body.get("card") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/coupon.py b/processout/coupon.py index 86245be..c8d41c7 100755 --- a/processout/coupon.py +++ b/processout/coupon.py @@ -311,9 +311,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["coupon"] + body = body.get("coupon") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -334,10 +336,12 @@ def find(self, coupon_id, options={}): return_values = [] body = response.body - body = body["coupon"] + body = body.get("coupon") + + if body is not None: - obj = processout.Coupon(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Coupon(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -358,9 +362,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["coupon"] + body = body.get("coupon") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/customer.py b/processout/customer.py index ebd4ebd..02c5f10 100755 --- a/processout/customer.py +++ b/processout/customer.py @@ -709,9 +709,10 @@ def find_token(self, token_id, options={}): return_values = [] body = response.body - body = body["token"] - token = processout.Token(self._client) - return_values.append(token.fill_with_data(body)) + body = body.get("token") + if body is not None: + token = processout.Token(self._client) + return_values.append(token.fill_with_data(body)) return return_values[0] @@ -829,9 +830,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["customer"] + body = body.get("customer") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -852,10 +855,12 @@ def find(self, customer_id, options={}): return_values = [] body = response.body - body = body["customer"] + body = body.get("customer") + + if body is not None: - obj = processout.Customer(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Customer(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -896,9 +901,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["customer"] + body = body.get("customer") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/discount.py b/processout/discount.py index 6f8cd73..d334c8a 100755 --- a/processout/discount.py +++ b/processout/discount.py @@ -344,9 +344,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["discount"] + body = body.get("discount") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -369,10 +371,12 @@ def find(self, subscription_id, discount_id, options={}): return_values = [] body = response.body - body = body["discount"] + body = body.get("discount") + + if body is not None: - obj = processout.Discount(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Discount(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/errorcodes.py b/processout/errorcodes.py index 789d6f1..3ac0fb5 100755 --- a/processout/errorcodes.py +++ b/processout/errorcodes.py @@ -73,8 +73,9 @@ def all(self, options={}): return_values = [] body = response.body + if body is not None: - obj = processout.ErrorCodes(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.ErrorCodes(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/event.py b/processout/event.py index 4b1336a..f2dff4d 100755 --- a/processout/event.py +++ b/processout/event.py @@ -229,9 +229,11 @@ def find(self, event_id, options={}): return_values = [] body = response.body - body = body["event"] + body = body.get("event") - obj = processout.Event(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Event(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/exportlayout.py b/processout/exportlayout.py index 8d60e3a..323721b 100755 --- a/processout/exportlayout.py +++ b/processout/exportlayout.py @@ -228,10 +228,12 @@ def find(self, export_layout_id, options={}): return_values = [] body = response.body - body = body["export_layout"] + body = body.get("export_layout") - obj = processout.ExportLayout(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.ExportLayout(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -252,10 +254,12 @@ def find_default(self, export_type, options={}): return_values = [] body = response.body - body = body["export_layout"] + body = body.get("export_layout") + + if body is not None: - obj = processout.ExportLayout(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.ExportLayout(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -279,9 +283,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["export_layout"] + body = body.get("export_layout") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -304,9 +310,11 @@ def update(self, export_layout_id, options={}): return_values = [] body = response.body - body = body["export_layout"] + body = body.get("export_layout") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/exportlayoutconfigurationoptions.py b/processout/exportlayoutconfigurationoptions.py index 050655c..bb8a51d 100755 --- a/processout/exportlayoutconfigurationoptions.py +++ b/processout/exportlayoutconfigurationoptions.py @@ -118,9 +118,11 @@ def fetch(self, export_type, options={}): return_values = [] body = response.body - body = body["export_layout_configuration_options"] + body = body.get("export_layout_configuration_options") - obj = processout.ExportLayoutConfigurationOptions(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.ExportLayoutConfigurationOptions(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/gatewayconfiguration.py b/processout/gatewayconfiguration.py index 5a9fd6a..347184d 100755 --- a/processout/gatewayconfiguration.py +++ b/processout/gatewayconfiguration.py @@ -313,10 +313,12 @@ def find(self, configuration_id, options={}): return_values = [] body = response.body - body = body["gateway_configuration"] + body = body.get("gateway_configuration") - obj = processout.GatewayConfiguration(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.GatewayConfiguration(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -344,9 +346,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["gateway_configuration"] + body = body.get("gateway_configuration") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -395,8 +399,10 @@ def create(self, gateway_name, options={}): return_values = [] body = response.body - body = body["gateway_configuration"] + body = body.get("gateway_configuration") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/invoice.py b/processout/invoice.py index d04d983..2a8f9a9 100755 --- a/processout/invoice.py +++ b/processout/invoice.py @@ -1070,9 +1070,10 @@ def increment_authorization(self, amount, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) return return_values[0] @@ -1104,13 +1105,16 @@ def authorize(self, source, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) body = response.body - body = body["customer_action"] - customerAction = processout.CustomerAction(self._client) - return_values.append(customerAction.fill_with_data(body)) + body = body.get("customer_action") + if body is not None: + customerAction = processout.CustomerAction(self._client) + customerAction_filled = customerAction.fill_with_data(body) + setattr(return_values[0], "customer_action", customerAction_filled) return tuple(return_values) @@ -1143,13 +1147,16 @@ def capture(self, source, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) body = response.body - body = body["customer_action"] - customerAction = processout.CustomerAction(self._client) - return_values.append(customerAction.fill_with_data(body)) + body = body.get("customer_action") + if body is not None: + customerAction = processout.CustomerAction(self._client) + customerAction_filled = customerAction.fill_with_data(body) + setattr(return_values[0], "customer_action", customerAction_filled) return tuple(return_values) @@ -1170,9 +1177,10 @@ def fetch_customer(self, options={}): return_values = [] body = response.body - body = body["customer"] - customer = processout.Customer(self._client) - return_values.append(customer.fill_with_data(body)) + body = body.get("customer") + if body is not None: + customer = processout.Customer(self._client) + return_values.append(customer.fill_with_data(body)) return return_values[0] @@ -1193,9 +1201,10 @@ def assign_customer(self, customer_id, options={}): return_values = [] body = response.body - body = body["customer"] - customer = processout.Customer(self._client) - return_values.append(customer.fill_with_data(body)) + body = body.get("customer") + if body is not None: + customer = processout.Customer(self._client) + return_values.append(customer.fill_with_data(body)) return return_values[0] @@ -1218,9 +1227,10 @@ def payout(self, gateway_configuration_id, source, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) return return_values[0] @@ -1247,10 +1257,12 @@ def show_native_payment_transaction( return_values = [] body = response.body - body = body["native_apm"] - nativeAPMTransactionDetails = processout.NativeAPMTransactionDetails( - self._client) - return_values.append(nativeAPMTransactionDetails.fill_with_data(body)) + body = body.get("native_apm") + if body is not None: + nativeAPMTransactionDetails = processout.NativeAPMTransactionDetails( + self._client) + return_values.append( + nativeAPMTransactionDetails.fill_with_data(body)) return return_values[0] @@ -1272,13 +1284,16 @@ def process_native_payment(self, invoice_id, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) body = response.body - body = body["native_apm"] - nativeAPMResponse = processout.NativeAPMResponse(self._client) - return_values.append(nativeAPMResponse.fill_with_data(body)) + body = body.get("native_apm") + if body is not None: + nativeAPMResponse = processout.NativeAPMResponse(self._client) + nativeAPMResponse_filled = nativeAPMResponse.fill_with_data(body) + setattr(return_values[0], "native_apm", nativeAPMResponse_filled) return tuple(return_values) @@ -1300,9 +1315,10 @@ def initiate_three_d_s(self, source, options={}): return_values = [] body = response.body - body = body["customer_action"] - customerAction = processout.CustomerAction(self._client) - return_values.append(customerAction.fill_with_data(body)) + body = body.get("customer_action") + if body is not None: + customerAction = processout.CustomerAction(self._client) + return_values.append(customerAction.fill_with_data(body)) return return_values[0] @@ -1323,9 +1339,10 @@ def fetch_transaction(self, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) return return_values[0] @@ -1347,9 +1364,10 @@ def void(self, options={}): return_values = [] body = response.body - body = body["transaction"] - transaction = processout.Transaction(self._client) - return_values.append(transaction.fill_with_data(body)) + body = body.get("transaction") + if body is not None: + transaction = processout.Transaction(self._client) + return_values.append(transaction.fill_with_data(body)) return return_values[0] @@ -1432,9 +1450,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["invoice"] + body = body.get("invoice") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -1455,10 +1475,12 @@ def find(self, invoice_id, options={}): return_values = [] body = response.body - body = body["invoice"] + body = body.get("invoice") + + if body is not None: - obj = processout.Invoice(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Invoice(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -1499,10 +1521,12 @@ def sync_with_psp(self, invoice_id, options={}): return_values = [] body = response.body - body = body["invoice"] + body = body.get("invoice") - obj = processout.Invoice(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Invoice(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -1526,8 +1550,10 @@ def update(self, invoice_id, options={}): return_values = [] body = response.body - body = body["invoice"] + body = body.get("invoice") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/payout.py b/processout/payout.py index f01a615..8e1ae1b 100755 --- a/processout/payout.py +++ b/processout/payout.py @@ -450,10 +450,12 @@ def find(self, payout_id, options={}): return_values = [] body = response.body - body = body["payout"] + body = body.get("payout") - obj = processout.Payout(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Payout(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/plan.py b/processout/plan.py index ea39d2a..e316612 100755 --- a/processout/plan.py +++ b/processout/plan.py @@ -329,9 +329,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["plan"] + body = body.get("plan") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -352,10 +354,12 @@ def find(self, plan_id, options={}): return_values = [] body = response.body - body = body["plan"] + body = body.get("plan") + + if body is not None: - obj = processout.Plan(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Plan(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -380,9 +384,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["plan"] + body = body.get("plan") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/product.py b/processout/product.py index 8d49573..386ab45 100755 --- a/processout/product.py +++ b/processout/product.py @@ -260,9 +260,10 @@ def create_invoice(self, options={}): return_values = [] body = response.body - body = body["invoice"] - invoice = processout.Invoice(self._client) - return_values.append(invoice.fill_with_data(body)) + body = body.get("invoice") + if body is not None: + invoice = processout.Invoice(self._client) + return_values.append(invoice.fill_with_data(body)) return return_values[0] @@ -315,9 +316,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["product"] + body = body.get("product") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -338,10 +341,12 @@ def find(self, product_id, options={}): return_values = [] body = response.body - body = body["product"] + body = body.get("product") + + if body is not None: - obj = processout.Product(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Product(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -367,9 +372,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["product"] + body = body.get("product") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/project.py b/processout/project.py index 788c597..28d2581 100755 --- a/processout/project.py +++ b/processout/project.py @@ -264,9 +264,11 @@ def fetch(self, options={}): return_values = [] body = response.body - body = body["project"] + body = body.get("project") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -287,9 +289,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["project"] + body = body.get("project") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -362,8 +366,10 @@ def create_supervised(self, options={}): return_values = [] body = response.body - body = body["project"] + body = body.get("project") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/projectsftpsettingspublic.py b/processout/projectsftpsettingspublic.py index e1446d4..96791b6 100755 --- a/processout/projectsftpsettingspublic.py +++ b/processout/projectsftpsettingspublic.py @@ -98,9 +98,11 @@ def fetch_sftp_settings(self, id, options={}): return_values = [] body = response.body - body = body["sftp_settings"] + body = body.get("sftp_settings") - obj = processout.ProjectSFTPSettingsPublic(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.ProjectSFTPSettingsPublic(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/refund.py b/processout/refund.py index b520041..e24d18b 100755 --- a/processout/refund.py +++ b/processout/refund.py @@ -296,10 +296,12 @@ def find(self, transaction_id, refund_id, options={}): return_values = [] body = response.body - body = body["refund"] + body = body.get("refund") - obj = processout.Refund(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Refund(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/processout/subscription.py b/processout/subscription.py index a07a970..975cc21 100755 --- a/processout/subscription.py +++ b/processout/subscription.py @@ -742,9 +742,10 @@ def find_addon(self, addon_id, options={}): return_values = [] body = response.body - body = body["addon"] - addon = processout.Addon(self._client) - return_values.append(addon.fill_with_data(body)) + body = body.get("addon") + if body is not None: + addon = processout.Addon(self._client) + return_values.append(addon.fill_with_data(body)) return return_values[0] @@ -788,9 +789,10 @@ def fetch_customer(self, options={}): return_values = [] body = response.body - body = body["customer"] - customer = processout.Customer(self._client) - return_values.append(customer.fill_with_data(body)) + body = body.get("customer") + if body is not None: + customer = processout.Customer(self._client) + return_values.append(customer.fill_with_data(body)) return return_values[0] @@ -839,9 +841,10 @@ def find_discount(self, discount_id, options={}): return_values = [] body = response.body - body = body["discount"] - discount = processout.Discount(self._client) - return_values.append(discount.fill_with_data(body)) + body = body.get("discount") + if body is not None: + discount = processout.Discount(self._client) + return_values.append(discount.fill_with_data(body)) return return_values[0] @@ -949,9 +952,11 @@ def create(self, options={}): return_values = [] body = response.body - body = body["subscription"] + body = body.get("subscription") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -972,10 +977,12 @@ def find(self, subscription_id, options={}): return_values = [] body = response.body - body = body["subscription"] + body = body.get("subscription") + + if body is not None: - obj = processout.Subscription(self._client) - return_values.append(obj.fill_with_data(body)) + obj = processout.Subscription(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -1006,9 +1013,11 @@ def save(self, options={}): return_values = [] body = response.body - body = body["subscription"] + body = body.get("subscription") - return_values.append(self.fill_with_data(body)) + if body is not None: + + return_values.append(self.fill_with_data(body)) return return_values[0] @@ -1031,8 +1040,10 @@ def cancel(self, options={}): return_values = [] body = response.body - body = body["subscription"] + body = body.get("subscription") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/token.py b/processout/token.py index 693a6f7..1005620 100755 --- a/processout/token.py +++ b/processout/token.py @@ -503,10 +503,12 @@ def find(self, customer_id, token_id, options={}): return_values = [] body = response.body - body = body["token"] + body = body.get("token") - obj = processout.Token(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Token(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] @@ -542,14 +544,18 @@ def create(self, options={}): return_values = [] body = response.body - body = body["token"] + body = body.get("token") + + if body is not None: - return_values.append(self.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) body = response.body - body = body["customer_action"] - customerAction = processout.CustomerAction(self._client) - return_values.append(customerAction.fill_with_data(body)) + body = body.get("customer_action") + if body is not None: + customerAction = processout.CustomerAction(self._client) + customerAction_filled = customerAction.fill_with_data(body) + setattr(return_values[0], "customer_action", customerAction_filled) return tuple(return_values) diff --git a/processout/transaction.py b/processout/transaction.py index 013e888..9cd6ef0 100755 --- a/processout/transaction.py +++ b/processout/transaction.py @@ -1330,9 +1330,10 @@ def find_refund(self, refund_id, options={}): return_values = [] body = response.body - body = body["refund"] - refund = processout.Refund(self._client) - return_values.append(refund.fill_with_data(body)) + body = body.get("refund") + if body is not None: + refund = processout.Refund(self._client) + return_values.append(refund.fill_with_data(body)) return return_values[0] @@ -1407,9 +1408,11 @@ def find(self, transaction_id, options={}): return_values = [] body = response.body - body = body["transaction"] + body = body.get("transaction") - obj = processout.Transaction(self._client) - return_values.append(obj.fill_with_data(body)) + if body is not None: + + obj = processout.Transaction(self._client) + return_values.append(obj.fill_with_data(body)) return return_values[0] diff --git a/setup.py b/setup.py index ab66970..b6b5eac 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setup( name = 'processout', packages = ['processout', 'processout.errors', 'processout.networking'], - version = '7.4.0', + version = '8.0.0', description = 'ProcessOut API bindings.', author = 'ProcessOut', author_email = 'hi@processout.com', url = 'https://github.com/processout/processout-python', - download_url = 'https://github.com/processout/processout-python/tarball/7.4.0', + download_url = 'https://github.com/processout/processout-python/tarball/8.0.0', keywords = ['ProcessOut', 'api', 'bindings'], classifiers = [], )