Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BalanceTransactionSourceId should include ReserveTransaction #572

Open
pdoms opened this issue Jul 18, 2024 · 3 comments
Open

BalanceTransactionSourceId should include ReserveTransaction #572

pdoms opened this issue Jul 18, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@pdoms
Copy link

pdoms commented Jul 18, 2024

Describe the bug

When listing BalanceTransactions deserialization fails at path to data.source if the source is a ReserveTransaction (with prefix rtx_).

To Reproduce

  1. Have a ReserveTransaction (Reserved Funds) in your stripe environment
  2. Call BalanceTransaction::list - no specific params or specify params.type_ = Some(BalanceTransactionType::ReserveTransaction.as_str());

Expected behavior

If the BalanceTransaction is of type ReserveTransaction Deserialization should work.

Code snippets

No response

OS

Ubuntu 22.04

Rust version

1.77.1 2024-03-27

Library version

async-stripe 0.37.1

API version

2022-08-01

Additional context

I assume it is a bug origination in the openAPI specs for stripe and thus incorrect code generation.

However, a manual/temporary fix could be the following.

src/ids.rs

def_id!(ReserveTransactionId, "rtx_"); //changed from "rtx" to "rtx_"
[...]
def_id!(
    #[optional]
    enum BalanceTransactionSourceId {
       [...]
        TransferReversal(TransferReversalId),
        ReserveTransaction(ReserveTransactionId),
    }
);

src/resources/balance_transactions_ext.rs

impl Object for BalanceTransactionSourceUnion {
    type Id = BalanceTransactionSourceId;
    fn id(&self) -> Self::Id {
        use BalanceTransactionSourceId as Id;
        use BalanceTransactionSourceUnion as Source;

        match self {
            [...]
            Source::ReserveTransaction(x) => Id::ReserveTransaction(x.id()), //from Id::None
            [...]
        }
    }
@pdoms pdoms added the bug Something isn't working label Jul 18, 2024
@arlyon
Copy link
Owner

arlyon commented Jul 23, 2024

I have opened a PR to change the ID to rtx_, that was an oversight thanks for reporting!

@arlyon arlyon mentioned this issue Jul 23, 2024
2 tasks
@arlyon
Copy link
Owner

arlyon commented Jul 23, 2024

Please let me know if that PR solves your issue

@pdoms
Copy link
Author

pdoms commented Jul 24, 2024

Thanks @arlyon for the swift response to this. I have tried it with 0.37.2 but unfortunately the error still persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants