Skip to content

fix: deserialize namespaced TaxNumberType and RECEIPT linked transactions - #243

Open
ryanduguid wants to merge 1 commit into
XeroAPI:masterfrom
ryanduguid:fix/deserialize-live-api-enums
Open

fix: deserialize namespaced TaxNumberType and RECEIPT linked transactions#243
ryanduguid wants to merge 1 commit into
XeroAPI:masterfrom
ryanduguid:fix/deserialize-live-api-enums

Conversation

@ryanduguid

Copy link
Copy Markdown

Fixes #203, #205, #206.

The Accounting API returns enum members this generated SDK does not list:

  • Contact `TaxNumberType`: `TAXNUMBERTYPE/SSN` (and the same prefix on other members)
  • LinkedTransaction `SourceTransactionTypeCode`: `RECEIPT` for receive-money bank transactions

Those values hit a closed `allowed_values` setter and raise `ValueError`, so an otherwise valid GET payload cannot be deserialized. Callers have been monkey-patching the setter.

This change lives in the non-generated deserializer:

  1. Construct as today when the value is in the spec.
  2. If a setter raises, retry with the suffix after `/` (`TAXNUMBERTYPE/SSN` → `SSN`).
  3. If it still raises, store the raw API value on the private field so the rest of the object is kept.

Companion spec patch: Xero-OpenAPI (RECEIPT on `SourceTransactionTypeCode`, note on namespaced tax number types). Regenerating models alone would still leave in-flight SDK users broken until the next release; this unblocks them now.

Test plan

  • `pytest tests/test_api_client/test_deserializer.py` (65 passing)
  • flake8 on the touched files
  • CI

…nums

Generated setters reject TaxNumberType TAXNUMBERTYPE/SSN (XeroAPI#203, XeroAPI#205) and
LinkedTransaction SourceTransactionTypeCode RECEIPT (XeroAPI#206). Deserialization
now retries namespaced values as their suffix, then preserves the raw API
value on the private field so one unknown enum cannot drop a valid payload.

Valid members (EIN, ACCPAY, SPEND) still go through the generated setters.
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.

get_contacts tax_number_type, invalid value "TAXNUMBERTYPE/SSN"

2 participants