ENG-4513: Sync AuthorizationDTO and RichMerchantData with Unit API docs#70
Merged
Merged
Conversation
samuelvasco
approved these changes
May 13, 2026
samuelvasco
reviewed
May 13, 2026
| Coordinates.from_json_api(data.get("coordinates")), | ||
| RichMerchantDataFacilitator.from_json_api(data.get("facilitators"))) | ||
| return RichMerchantData( | ||
| name=data["name"], |
Collaborator
There was a problem hiding this comment.
praise: the keyname args are so much cleaner 🫧
Merge activity
|
…cs (#70) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Brings `AuthorizationDTO` and `RichMerchantData` in sync with [Unit's API documentation](https://www.unit.co/docs/api/resources/#authorization). ## Changes ### `AuthorizationDTO` — new fields The following optional fields were missing from `AuthorizationDTO` compared to what Unit's API actually returns: | Field | Type | When present | |-------|------|-------------| | `declineReason` | `str` | When status is `Declined` | | `declineDescription` | `str` | Some declined authorizations | | `declinedBy` | `str` (`Visa`, `Org`, `Unit`) | When status is `Declined` | | `paymentMethod` | `str` (`Manual`, `Swipe`, `Contactless`, `ChipAndPin`, `Stored`, `Other`) | Optional | | `digitalWallet` | `str` (`Google`, `Apple`, `Other`) | Optional | | `cardVerificationData` | `CardVerificationData` | Optional | | `cardNetwork` | `str` (`Visa`, `Interlink`, `Accel`, `Allpoint`, `Other`) | Optional | | `cashWithdrawalAmount` | `int` | Optional | | `summary` | `str` | Optional | | `richMerchantData` | `RichMerchantData` | When transaction enrichment is enabled | | `currencyConversion` | `CurrencyConversion` | When original currency is not USD | ### `RichMerchantData` — bug fix `RichMerchantData.from_json_api` was passing the raw `address` dict through without deserializing it via `RichMerchantDataAddress.from_json_api`. This meant the `address` attribute was a plain dict at runtime instead of a typed `RichMerchantDataAddress` object. Fixed to properly deserialize. ### New type: `CardVerificationData` Added to `unit/models/__init__.py` to represent the nested `cardVerificationData` object with its `verificationMethod` field. ### Style Switched both `AuthorizationDTO` and `RichMerchantData` constructors/factories to use keyword arguments per SDK conventions. ## Backward compatibility All new `AuthorizationDTO` fields are optional with `None` defaults. The constructor signature is compatible with existing callers — the only construction site is `from_json_api` which now uses keyword arguments. The `RichMerchantData` address fix is a strict improvement (typed object instead of raw dict). <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-072af5b8-dd43-4652-835b-f790e0c237be"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-072af5b8-dd43-4652-835b-f790e0c237be"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
86b3f28 to
75613da
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings
AuthorizationDTOandRichMerchantDatain sync with Unit's API documentation.Changes
AuthorizationDTO— new fieldsThe following optional fields were missing from
AuthorizationDTOcompared to what Unit's API actually returns:declineReasonstrDeclineddeclineDescriptionstrdeclinedBystr(Visa,Org,Unit)DeclinedpaymentMethodstr(Manual,Swipe,Contactless,ChipAndPin,Stored,Other)digitalWalletstr(Google,Apple,Other)cardVerificationDataCardVerificationDatacardNetworkstr(Visa,Interlink,Accel,Allpoint,Other)cashWithdrawalAmountintsummarystrrichMerchantDataRichMerchantDatacurrencyConversionCurrencyConversionRichMerchantData— bug fixRichMerchantData.from_json_apiwas passing the rawaddressdict through without deserializing it viaRichMerchantDataAddress.from_json_api. This meant theaddressattribute was a plain dict at runtime instead of a typedRichMerchantDataAddressobject. Fixed to properly deserialize.New type:
CardVerificationDataAdded to
unit/models/__init__.pyto represent the nestedcardVerificationDataobject with itsverificationMethodfield.Style
Switched both
AuthorizationDTOandRichMerchantDataconstructors/factories to use keyword arguments per SDK conventions.Backward compatibility
All new
AuthorizationDTOfields are optional withNonedefaults. The constructor signature is compatible with existing callers — the only construction site isfrom_json_apiwhich now uses keyword arguments. TheRichMerchantDataaddress fix is a strict improvement (typed object instead of raw dict).