From 61e954198feb655d3061eb91decdafb820a6114d Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Wed, 12 Jun 2024 12:46:47 +0300 Subject: [PATCH] added method for fetching client wallet transactions --- mangopay/resources.py | 10 +++++++++- tests/test_client_wallets.py | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mangopay/resources.py b/mangopay/resources.py index c524e84..9c1606d 100644 --- a/mangopay/resources.py +++ b/mangopay/resources.py @@ -1609,7 +1609,8 @@ class Meta: 'MANDATE_GET_TRANSACTIONS': '/mandates/%(id)s/transactions', 'CARD_GET_TRANSACTIONS': '/cards/%(id)s/transactions', 'BANK_ACCOUNT_GET_TRANSACTIONS': '/bankaccounts/%(id)s/transactions', - 'PRE_AUTHORIZATION_TRANSACTIONS': '/preauthorizations/%(id)s/transactions' + 'PRE_AUTHORIZATION_TRANSACTIONS': '/preauthorizations/%(id)s/transactions', + 'CLIENT_WALLET_TRANSACTIONS': '/clients/wallets/%(fund_type)s/%(currency)s/transactions' } def __str__(self): @@ -1677,6 +1678,13 @@ def all_by_funds_type(cls, fund_type, *args, **kwargs): select.identifier = cls._meta.fund_type_url[fund_type] return select.all(*args, **kwargs) + def get_transactions(cls, fund_type, currency, **kwargs): + kwargs['fund_type'], kwargs['currency'] = fund_type, currency + args = '', + select = SelectQuery(Transaction, *args, **kwargs) + select.identifier = 'CLIENT_WALLET_TRANSACTIONS' + return select.all(*args, **kwargs) + def get_pk(self): return getattr(self, 'id', None) diff --git a/tests/test_client_wallets.py b/tests/test_client_wallets.py index 2ea87b9..7de071d 100644 --- a/tests/test_client_wallets.py +++ b/tests/test_client_wallets.py @@ -190,3 +190,11 @@ def test_ViewClientWalletsByFunds(self): self.assertIsNotNone(result) self.assertTrue(result.funds_type == wallet.funds_type) self.assertTrue(result.currency == wallet.currency) + + def test_ViewClientTransactions(self): + wallets = ClientWallet.all() + client_wallet = wallets[0] + client_wallet_transactions = client_wallet.get_transactions(client_wallet.funds_type, client_wallet.currency) + self.assertIsNotNone(client_wallet_transactions) + self.assertTrue(len(client_wallet_transactions) > 0) +