From 435fedecd77f3fc917d48d3a9d2901df32bc0f46 Mon Sep 17 00:00:00 2001 From: Avery Kushner Date: Thu, 30 Oct 2025 16:19:16 -0400 Subject: [PATCH 1/2] Handle absent merchants in adjustment transactions --- unit/models/__init__.py | 5 ++++- unit/models/transaction.py | 12 +++++++----- unit_python_sdk.egg-info/PKG-INFO | 12 +++++++++++- unit_python_sdk.egg-info/SOURCES.txt | 2 ++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/unit/models/__init__.py b/unit/models/__init__.py index 19c3d2c3..88e69d0f 100644 --- a/unit/models/__init__.py +++ b/unit/models/__init__.py @@ -444,7 +444,10 @@ def __init__( self.id = _id @staticmethod - def from_json_api(data: Dict): + def from_json_api(data: Dict = None): + if data is None: + return None + return Merchant( data["name"], data["type"], data.get("category"), data.get("location"), data.get("id") ) diff --git a/unit/models/transaction.py b/unit/models/transaction.py index 8d66e046..4f5ed862 100644 --- a/unit/models/transaction.py +++ b/unit/models/transaction.py @@ -131,7 +131,7 @@ def from_json_api(_id, _type, attributes, relationships): class PurchaseTransactionDTO(BaseTransactionDTO): def __init__(self, id: str, created_at: datetime, direction: str, amount: int, balance: int, - summary: str, card_last_4_digits: str, merchant: Merchant, coordinates: Optional[Coordinates], + summary: str, card_last_4_digits: str, merchant: Optional[Merchant], coordinates: Optional[Coordinates], recurring: bool, ecommerce: bool, card_present: bool, card_verification_data, interchange: Optional[int] = None, payment_method: Optional[str] = None, digital_wallet: Optional[str] = None, card_network: Optional[str] = None, @@ -142,7 +142,8 @@ def __init__(self, id: str, created_at: datetime, direction: str, amount: int, b BaseTransactionDTO.__init__(self, id, created_at, direction, amount, balance, summary, tags, relationships) self.type = 'purchaseTransaction' self.attributes["cardLast4Digits"] = card_last_4_digits - self.attributes["merchant"] = merchant + if merchant: + self.attributes["merchant"] = merchant self.attributes["coordinates"] = coordinates self.attributes["recurring"] = recurring self.attributes["interchange"] = interchange @@ -219,14 +220,15 @@ def from_json_api(_id, _type, attributes, relationships): class CardTransactionDTO(BaseTransactionDTO): def __init__(self, id: str, created_at: datetime, direction: str, amount: int, balance: int, - summary: str, card_last_4_digits: str, merchant: Merchant, recurring: Optional[bool], + summary: str, card_last_4_digits: str, merchant: Optional[Merchant], recurring: Optional[bool], interchange: Optional[int], payment_method: Optional[str], digital_wallet: Optional[str], card_verification_data: Optional[Dict], card_network: Optional[str], tags: Optional[Dict[str, str]], relationships: Optional[Dict[str, Relationship]]): BaseTransactionDTO.__init__(self, id, created_at, direction, amount, balance, summary, tags, relationships) self.type = 'cardTransaction' self.attributes["cardLast4Digits"] = card_last_4_digits - self.attributes["merchant"] = merchant + if merchant: + self.attributes["merchant"] = merchant self.attributes["recurring"] = recurring self.attributes["interchange"] = interchange self.attributes["paymentMethod"] = payment_method @@ -239,7 +241,7 @@ def __init__(self, id: str, created_at: datetime, direction: str, amount: int, b def from_json_api(_id, _type, attributes, relationships): return CardTransactionDTO(_id, date_utils.to_datetime(attributes["createdAt"]), attributes["direction"], attributes["amount"], attributes["balance"], attributes["summary"], - attributes["cardLast4Digits"], Merchant.from_json_api(attributes["merchant"]), + attributes["cardLast4Digits"], Merchant.from_json_api(attributes.get("merchant")), attributes.get("recurring"), attributes.get("interchange"), attributes.get("paymentMethod"), attributes.get("digitalWallet"), attributes.get("cardVerificationData"), attributes.get("cardNetwork"), diff --git a/unit_python_sdk.egg-info/PKG-INFO b/unit_python_sdk.egg-info/PKG-INFO index f8e13e2e..c11c3a0c 100644 --- a/unit_python_sdk.egg-info/PKG-INFO +++ b/unit_python_sdk.egg-info/PKG-INFO @@ -1,4 +1,4 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.4 Name: unit-python-sdk Version: 0.10.5 Summary: This library provides a python wrapper to http://unit.co API. See https://docs.unit.co/ @@ -17,3 +17,13 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 License-File: LICENSE Requires-Dist: requests +Dynamic: author +Dynamic: author-email +Dynamic: classifier +Dynamic: download-url +Dynamic: home-page +Dynamic: keywords +Dynamic: license +Dynamic: license-file +Dynamic: requires-dist +Dynamic: summary diff --git a/unit_python_sdk.egg-info/SOURCES.txt b/unit_python_sdk.egg-info/SOURCES.txt index f4f690c1..1b8d9a51 100644 --- a/unit_python_sdk.egg-info/SOURCES.txt +++ b/unit_python_sdk.egg-info/SOURCES.txt @@ -19,6 +19,7 @@ unit/api/bill_pay_resource.py unit/api/card_resource.py unit/api/check_deposit_resource.py unit/api/check_payment_resource.py +unit/api/check_registered_address.py unit/api/check_stop_payment_resource.py unit/api/counterparty_resource.py unit/api/customerToken_resource.py @@ -50,6 +51,7 @@ unit/models/bill_pay.py unit/models/card.py unit/models/check_deposit.py unit/models/check_payment.py +unit/models/check_registered_address.py unit/models/check_stop_payment.py unit/models/codecs.py unit/models/counterparty.py From bfab1143e6712d26038ee5b596a0b6250913bbcb Mon Sep 17 00:00:00 2001 From: Avery Kushner Date: Thu, 30 Oct 2025 16:21:33 -0400 Subject: [PATCH 2/2] Revert sources/package info changes --- unit_python_sdk.egg-info/PKG-INFO | 12 +----------- unit_python_sdk.egg-info/SOURCES.txt | 2 -- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/unit_python_sdk.egg-info/PKG-INFO b/unit_python_sdk.egg-info/PKG-INFO index c11c3a0c..f8e13e2e 100644 --- a/unit_python_sdk.egg-info/PKG-INFO +++ b/unit_python_sdk.egg-info/PKG-INFO @@ -1,4 +1,4 @@ -Metadata-Version: 2.4 +Metadata-Version: 2.1 Name: unit-python-sdk Version: 0.10.5 Summary: This library provides a python wrapper to http://unit.co API. See https://docs.unit.co/ @@ -17,13 +17,3 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 License-File: LICENSE Requires-Dist: requests -Dynamic: author -Dynamic: author-email -Dynamic: classifier -Dynamic: download-url -Dynamic: home-page -Dynamic: keywords -Dynamic: license -Dynamic: license-file -Dynamic: requires-dist -Dynamic: summary diff --git a/unit_python_sdk.egg-info/SOURCES.txt b/unit_python_sdk.egg-info/SOURCES.txt index 1b8d9a51..f4f690c1 100644 --- a/unit_python_sdk.egg-info/SOURCES.txt +++ b/unit_python_sdk.egg-info/SOURCES.txt @@ -19,7 +19,6 @@ unit/api/bill_pay_resource.py unit/api/card_resource.py unit/api/check_deposit_resource.py unit/api/check_payment_resource.py -unit/api/check_registered_address.py unit/api/check_stop_payment_resource.py unit/api/counterparty_resource.py unit/api/customerToken_resource.py @@ -51,7 +50,6 @@ unit/models/bill_pay.py unit/models/card.py unit/models/check_deposit.py unit/models/check_payment.py -unit/models/check_registered_address.py unit/models/check_stop_payment.py unit/models/codecs.py unit/models/counterparty.py