Skip to content

ENG-4513: Sync AuthorizationDTO and RichMerchantData with Unit API docs#70

Merged
graphite-app[bot] merged 1 commit into
masterfrom
cursor/sync-authorization-dto-37be
May 13, 2026
Merged

ENG-4513: Sync AuthorizationDTO and RichMerchantData with Unit API docs#70
graphite-app[bot] merged 1 commit into
masterfrom
cursor/sync-authorization-dto-37be

Conversation

@julia-truss
Copy link
Copy Markdown
Collaborator

Summary

Brings AuthorizationDTO and RichMerchantData in sync with Unit's API documentation.

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).

Open in Web Open in Cursor 

@julia-truss julia-truss changed the title Sync AuthorizationDTO and RichMerchantData with Unit API docs ENG-4513: Sync AuthorizationDTO and RichMerchantData with Unit API docs May 13, 2026
@julia-truss julia-truss marked this pull request as ready for review May 13, 2026 17:24
Comment thread unit/models/__init__.py
Coordinates.from_json_api(data.get("coordinates")),
RichMerchantDataFacilitator.from_json_api(data.get("facilitators")))
return RichMerchantData(
name=data["name"],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: the keyname args are so much cleaner 🫧

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 13, 2026

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>&nbsp;<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>&nbsp;</div>
@graphite-app graphite-app Bot force-pushed the cursor/sync-authorization-dto-37be branch from 86b3f28 to 75613da Compare May 13, 2026 17:38
@graphite-app graphite-app Bot merged commit 75613da into master May 13, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants