Skip to content

Feature: Keep the raw PayWay response on parsed models - #10

Merged
napper1 merged 1 commit into
masterfrom
feature/keep-raw-response
Aug 12, 2026
Merged

Feature: Keep the raw PayWay response on parsed models#10
napper1 merged 1 commit into
masterfrom
feature/keep-raw-response

Conversation

@napper1

@napper1 napper1 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Parsing is lossy: from_dict only reads declared fields, so keys PayWay sends but the dataclass does not model are dropped (a real transaction loses creditCard.cardScheme and cardType), absent keys come back as explicit None, and aliases rename them — maskedCardNumber is parsed into card_number, a key PayWay never sent. to_dict() is therefore a projection of the response, not the response, which is not enough for callers who persist it for auditing, reconciliation or dispute resolution.

Models built by from_dict now keep that body verbatim on raw. It is annotated on the PayWayModel mixin, which is not a dataclass, so it never becomes a field: fields() ignores it and to_dict(), equality and repr are unchanged. PayWayCard reassigns it after parsing so the nested card keeps PayWay's own body rather than the copy rewritten for the cardNumber alias.

Parsing is lossy: from_dict only reads declared fields, so keys PayWay
sends but the dataclass does not model are dropped (a real transaction
loses creditCard.cardScheme and cardType), absent keys come back as
explicit None, and aliases rename them — maskedCardNumber is parsed into
card_number, a key PayWay never sent. to_dict() is therefore a projection
of the response, not the response, which is not enough for callers who
persist it for auditing, reconciliation or dispute resolution.

Models built by from_dict now keep that body verbatim on `raw`. It is
annotated on the PayWayModel mixin, which is not a dataclass, so it never
becomes a field: fields() ignores it and to_dict(), equality and repr are
unchanged. PayWayCard reassigns it after parsing so the nested card keeps
PayWay's own body rather than the copy rewritten for the cardNumber alias.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@napper1
napper1 merged commit b0a65a5 into master Aug 12, 2026
1 check 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.

1 participant