Skip to content

Commit

Permalink
Merge pull request #364 from Mangopay/feature/client-wallet-transactions
Browse files Browse the repository at this point in the history
added method for fetching client wallet transactions
  • Loading branch information
iulian03 authored Jun 12, 2024
2 parents 075f5eb + 61e9541 commit 622d2e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mangopay/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions tests/test_client_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 622d2e9

Please sign in to comment.