Skip to content

Commit a923a2a

Browse files
Merge pull request #47 from hyperwallet/feature/DTRUNEONE-1585-V3-python-Updating-request-query-parameters-of-list-methods
feature/DTPAYHWBM-7: V3 updated filters for list endpoints and relevant unit tests
2 parents 7a46016 + c0c5470 commit a923a2a

3 files changed

Lines changed: 402 additions & 29 deletions

File tree

hyperwallet/api.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,9 @@ def listVenmoAccounts(self,
18911891
if not userToken:
18921892
raise HyperwalletException('userToken is required')
18931893

1894+
if params and not set(list(params)).issubset(VenmoAccount.filters_array):
1895+
raise HyperwalletException('Invalid filter')
1896+
18941897
response = self.apiClient.doGet(
18951898
self.__buildUrl('users', userToken, 'venmo-accounts'),
18961899
params
@@ -1999,6 +2002,9 @@ def listVenmoAccountStatusTransitions(self,
19992002
if not venmoAccountToken:
20002003
raise HyperwalletException('venmoAccountToken is required')
20012004

2005+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
2006+
raise HyperwalletException('Invalid filter')
2007+
20022008
response = self.apiClient.doGet(
20032009
self.__buildUrl(
20042010
'users',
@@ -2248,7 +2254,7 @@ def listBalancesForUser(self,
22482254
if not userToken:
22492255
raise HyperwalletException('userToken is required')
22502256

2251-
if params and not set(list(params)).issubset(Balance.filters_array):
2257+
if params and not set(list(params)).issubset(Balance.filters_array_user):
22522258
raise HyperwalletException('Invalid filter')
22532259

22542260
response = self.apiClient.doGet(
@@ -2281,7 +2287,7 @@ def listBalancesForPrepaidCard(self,
22812287
if not prepaidCardToken:
22822288
raise HyperwalletException('prepaidCardToken is required')
22832289

2284-
if params and not set(list(params)).issubset(Balance.filters_array):
2290+
if params and not set(list(params)).issubset(Balance.filters_array_prepaid_card):
22852291
raise HyperwalletException('Invalid filter')
22862292

22872293
response = self.apiClient.doGet(
@@ -2320,7 +2326,7 @@ def listBalancesForAccount(self,
23202326
if not accountToken:
23212327
raise HyperwalletException('accountToken is required')
23222328

2323-
if params and not set(list(params)).issubset(Balance.filters_array):
2329+
if params and not set(list(params)).issubset(Balance.filters_array_account):
23242330
raise HyperwalletException('Invalid filter')
23252331

23262332
response = self.apiClient.doGet(
@@ -2360,6 +2366,9 @@ def listReceiptsForUser(self,
23602366
if not userToken:
23612367
raise HyperwalletException('userToken is required')
23622368

2369+
if params and not set(list(params)).issubset(Receipt.filters_array_user):
2370+
raise HyperwalletException('Invalid filter')
2371+
23632372
response = self.apiClient.doGet(
23642373
self.__buildUrl('users', userToken, 'receipts'),
23652374
params
@@ -2390,6 +2399,9 @@ def listReceiptsForPrepaidCard(self,
23902399
if not prepaidCardToken:
23912400
raise HyperwalletException('prepaidCardToken is required')
23922401

2402+
if params and not set(list(params)).issubset(Receipt.filters_array_prepaid_card):
2403+
raise HyperwalletException('Invalid filter')
2404+
23932405
response = self.apiClient.doGet(
23942406
self.__buildUrl(
23952407
'users',
@@ -2426,6 +2438,9 @@ def listReceiptsForAccount(self,
24262438
if not accountToken:
24272439
raise HyperwalletException('accountToken is required')
24282440

2441+
if params and not set(list(params)).issubset(Receipt.filters_array_account):
2442+
raise HyperwalletException('Invalid filter')
2443+
24292444
response = self.apiClient.doGet(
24302445
self.__buildUrl(
24312446
'programs',
@@ -2628,6 +2643,9 @@ def listTransferMethodConfigurations(self,
26282643
if not userToken:
26292644
raise HyperwalletException('userToken is required')
26302645

2646+
if params and not set(list(params)).issubset(TransferMethodConfiguration.filters_array):
2647+
raise HyperwalletException('Invalid filter')
2648+
26312649
params.update({'userToken': userToken})
26322650

26332651
response = self.apiClient.doGet(
@@ -3078,6 +3096,9 @@ def listTransferMethods(self,
30783096

30793097
if not userToken:
30803098
raise HyperwalletException('userToken is required')
3099+
3100+
if params and not set(list(params)).issubset(TransferMethod.filters_array):
3101+
raise HyperwalletException('Invalid filter')
30813102

30823103
response = self.apiClient.doGet(
30833104
self.__buildUrl(

hyperwallet/models.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class User(HyperwalletModel):
7070
A dictionary containing the attributes for the User.
7171
'''
7272

73-
filters_array = {'clientUserId', 'email', 'programToken', 'status', 'verificationStatus'}
73+
filters_array = {'clientUserId','email','programToken','status','verificationStatus', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
7474

7575
def __init__(self, data):
7676
'''
@@ -166,6 +166,8 @@ class TransferMethod(HyperwalletModel):
166166
A dictionary containing the attributes for the Transfer Method.
167167
'''
168168

169+
filters_array = {'status', 'type', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
170+
169171
def __init__(self, data):
170172
'''
171173
Create a new Transfer Method with the provided attributes.
@@ -201,7 +203,7 @@ class BankAccount(TransferMethod):
201203
A dictionary containing the attributes for the Bank Account.
202204
'''
203205

204-
filters_array = {'type', 'status'}
206+
filters_array = {'type','status', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
205207

206208
def __init__(self, data):
207209
'''
@@ -284,7 +286,7 @@ class BankCard(TransferMethod):
284286
A dictionary containing the attributes for the Bank Card.
285287
'''
286288

287-
filters_array = {'status'}
289+
filters_array = {'status', 'type', 'createdOn', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
288290

289291
def __init__(self, data):
290292
'''
@@ -320,7 +322,7 @@ class PrepaidCard(TransferMethod):
320322
A dictionary containing the attributes for the Prepaid Card.
321323
'''
322324

323-
filters_array = {'status'}
325+
filters_array = {'status', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
324326

325327
def __init__(self, data):
326328
'''
@@ -355,7 +357,7 @@ class PaperCheck(TransferMethod):
355357
A dictionary containing the attributes for the Paper Check.
356358
'''
357359

358-
filters_array = {'status'}
360+
filters_array = {'status', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
359361

360362
def __init__(self, data):
361363
'''
@@ -414,7 +416,7 @@ class Transfer(HyperwalletModel):
414416
A dictionary containing the attributes for the Transfer.
415417
'''
416418

417-
filters_array = {'clientTransferId', 'sourceToken', 'destinationToken'}
419+
filters_array = {'clientTransferId','sourceToken','destinationToken', 'createdBefore', 'createdAfter', 'offset', 'limit'}
418420

419421
def __init__(self, data):
420422
'''
@@ -460,7 +462,7 @@ class PayPalAccount(TransferMethod):
460462
A dictionary containing the attributes for the PayPal Account.
461463
'''
462464

463-
filters_array = {'status'}
465+
filters_array = {'status', 'type', 'createdOn' , 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
464466

465467
def __init__(self, data):
466468
'''
@@ -491,6 +493,8 @@ class VenmoAccount(TransferMethod):
491493
A dictionary containing the attributes for the Venmo Account.
492494
'''
493495

496+
filters_array = {'status', 'type', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
497+
494498
def __init__(self, data):
495499
'''
496500
Create a new Venmo Account with the provided attributes.
@@ -520,7 +524,7 @@ class Payment(HyperwalletModel):
520524
A dictionary containing the attributes for the Payment.
521525
'''
522526

523-
filters_array = {'clientPaymentId', 'releaseOn'}
527+
filters_array = {'clientPaymentId', 'currency', 'memo', 'releaseDate', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
524528

525529
def __init__(self, data):
526530
'''
@@ -564,7 +568,9 @@ class Balance(HyperwalletModel):
564568
A dictionary containing the attributes for the Balance.
565569
'''
566570

567-
filters_array = {'currency'}
571+
filters_array_user = {'currency', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
572+
filters_array_account = {'currency', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
573+
filters_array_prepaid_card = {'createdBefore', 'createdAfter'}
568574

569575
def __init__(self, data):
570576
'''
@@ -596,6 +602,10 @@ class Receipt(HyperwalletModel):
596602
A dictionary containing the attributes for the Receipt.
597603
'''
598604

605+
filters_array_user = {'currency', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
606+
filters_array_account = {'currency', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
607+
filters_array_prepaid_card = {'createdBefore', 'createdAfter'}
608+
599609
def __init__(self, data):
600610
'''
601611
Create a new Receipt with the provided attributes.
@@ -700,7 +710,7 @@ class StatusTransition(HyperwalletModel):
700710
A dictionary containing the attributes for the Status Transition.
701711
'''
702712

703-
filters_array = {'transition'}
713+
filters_array = {'transition', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
704714

705715
def __init__(self, data):
706716
'''
@@ -737,6 +747,8 @@ class TransferMethodConfiguration(HyperwalletModel):
737747
A dictionary containing the attributes for the Transfer Method Configuration.
738748
'''
739749

750+
filters_array = {'userToken', 'offset', 'limit'}
751+
740752
def __init__(self, data):
741753
'''
742754
Create a new Transfer Method Configuration with the provided attributes.
@@ -778,7 +790,7 @@ class Webhook(HyperwalletModel):
778790
A dictionary containing the attributes for the Webhook.
779791
'''
780792

781-
filters_array = {'programToken'}
793+
filters_array = {'programToken', 'type', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
782794

783795
def __init__(self, data):
784796
'''

0 commit comments

Comments
 (0)