Skip to content

Commit e7f470d

Browse files
Merge pull request #43 from hyperwallet/feature-V3/Filters
added filters
2 parents 22d1dbc + e3c6079 commit e7f470d

3 files changed

Lines changed: 200 additions & 10 deletions

File tree

hyperwallet/api.py

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def listUsers(self,
157157
An array of Users.
158158
'''
159159

160+
if params and not set(list(params)).issubset(User.filters_array):
161+
raise HyperwalletException('Invalid filter')
162+
160163
response = self.apiClient.doGet('users', params)
161164

162165
return [User(x) for x in response.get('data', [])]
@@ -209,6 +212,9 @@ def listUserStatusTransitions(self,
209212
if not userToken:
210213
raise HyperwalletException('userToken is required')
211214

215+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
216+
raise HyperwalletException('Invalid filter')
217+
212218
response = self.apiClient.doGet(
213219
self.__buildUrl(
214220
'users',
@@ -322,6 +328,9 @@ def listBankAccounts(self,
322328
if not userToken:
323329
raise HyperwalletException('userToken is required')
324330

331+
if params and not set(list(params)).issubset(BankAccount.filters_array):
332+
raise HyperwalletException('Invalid filter')
333+
325334
response = self.apiClient.doGet(
326335
self.__buildUrl('users', userToken, 'bank-accounts'),
327336
params
@@ -430,6 +439,9 @@ def listBankAccountStatusTransitions(self,
430439
if not bankAccountToken:
431440
raise HyperwalletException('bankAccountToken is required')
432441

442+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
443+
raise HyperwalletException('Invalid filter')
444+
433445
response = self.apiClient.doGet(
434446
self.__buildUrl(
435447
'users',
@@ -575,6 +587,9 @@ def listBankCards(self,
575587
if not userToken:
576588
raise HyperwalletException('userToken is required')
577589

590+
if params and not set(list(params)).issubset(BankCard.filters_array):
591+
raise HyperwalletException('Invalid filter')
592+
578593
response = self.apiClient.doGet(
579594
self.__buildUrl('users', userToken, 'bank-cards'),
580595
params
@@ -683,6 +698,9 @@ def listBankCardStatusTransitions(self,
683698
if not bankCardToken:
684699
raise HyperwalletException('bankCardToken is required')
685700

701+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
702+
raise HyperwalletException('Invalid filter')
703+
686704
response = self.apiClient.doGet(
687705
self.__buildUrl(
688706
'users',
@@ -828,6 +846,9 @@ def listPrepaidCards(self,
828846
if not userToken:
829847
raise HyperwalletException('userToken is required')
830848

849+
if params and not set(list(params)).issubset(PrepaidCard.filters_array):
850+
raise HyperwalletException('Invalid filter')
851+
831852
response = self.apiClient.doGet(
832853
self.__buildUrl('users', userToken, 'prepaid-cards'),
833854
params
@@ -936,6 +957,9 @@ def listPrepaidCardStatusTransitions(self,
936957
if not prepaidCardToken:
937958
raise HyperwalletException('prepaidCardToken is required')
938959

960+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
961+
raise HyperwalletException('Invalid filter')
962+
939963
response = self.apiClient.doGet(
940964
self.__buildUrl(
941965
'users',
@@ -1231,6 +1255,9 @@ def listPaperChecks(self,
12311255
if not userToken:
12321256
raise HyperwalletException('userToken is required')
12331257

1258+
if params and not set(list(params)).issubset(PaperCheck.filters_array):
1259+
raise HyperwalletException('Invalid filter')
1260+
12341261
response = self.apiClient.doGet(
12351262
self.__buildUrl('users', userToken, 'paper-checks'),
12361263
params
@@ -1339,6 +1366,9 @@ def listPaperCheckStatusTransitions(self,
13391366
if not paperCheckToken:
13401367
raise HyperwalletException('paperCheckToken is required')
13411368

1369+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
1370+
raise HyperwalletException('Invalid filter')
1371+
13421372
response = self.apiClient.doGet(
13431373
self.__buildUrl(
13441374
'users',
@@ -1450,6 +1480,9 @@ def listTransfers(self,
14501480
An array of Transfers.
14511481
'''
14521482

1483+
if params and not set(list(params)).issubset(Transfer.filters_array):
1484+
raise HyperwalletException('Invalid filter')
1485+
14531486
response = self.apiClient.doGet(
14541487
self.__buildUrl('transfers'),
14551488
params
@@ -1594,6 +1627,9 @@ def listPayPalAccounts(self,
15941627
if not userToken:
15951628
raise HyperwalletException('userToken is required')
15961629

1630+
if params and not set(list(params)).issubset(PayPalAccount.filters_array):
1631+
raise HyperwalletException('Invalid filter')
1632+
15971633
response = self.apiClient.doGet(
15981634
self.__buildUrl('users', userToken, 'paypal-accounts'),
15991635
params
@@ -1702,6 +1738,9 @@ def listPayPalAccountStatusTransitions(self,
17021738
if not payPalAccountToken:
17031739
raise HyperwalletException('payPalAccountToken is required')
17041740

1741+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
1742+
raise HyperwalletException('Invalid filter')
1743+
17051744
response = self.apiClient.doGet(
17061745
self.__buildUrl(
17071746
'users',
@@ -2085,6 +2124,9 @@ def listPayments(self,
20852124
An array of Payments.
20862125
'''
20872126

2127+
if params and not set(list(params)).issubset(Payment.filters_array):
2128+
raise HyperwalletException('Invalid filter')
2129+
20882130
response = self.apiClient.doGet('payments', params)
20892131

20902132
return [Payment(x) for x in response.get('data', [])]
@@ -2137,6 +2179,9 @@ def listPaymentStatusTransitions(self,
21372179
if not paymentToken:
21382180
raise HyperwalletException('paymentToken is required')
21392181

2182+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
2183+
raise HyperwalletException('Invalid filter')
2184+
21402185
response = self.apiClient.doGet(
21412186
self.__buildUrl(
21422187
'payments',
@@ -2203,6 +2248,9 @@ def listBalancesForUser(self,
22032248
if not userToken:
22042249
raise HyperwalletException('userToken is required')
22052250

2251+
if params and not set(list(params)).issubset(Balance.filters_array):
2252+
raise HyperwalletException('Invalid filter')
2253+
22062254
response = self.apiClient.doGet(
22072255
self.__buildUrl('users', userToken, 'balances'),
22082256
params
@@ -2233,6 +2281,9 @@ def listBalancesForPrepaidCard(self,
22332281
if not prepaidCardToken:
22342282
raise HyperwalletException('prepaidCardToken is required')
22352283

2284+
if params and not set(list(params)).issubset(Balance.filters_array):
2285+
raise HyperwalletException('Invalid filter')
2286+
22362287
response = self.apiClient.doGet(
22372288
self.__buildUrl(
22382289
'users',
@@ -2269,6 +2320,9 @@ def listBalancesForAccount(self,
22692320
if not accountToken:
22702321
raise HyperwalletException('accountToken is required')
22712322

2323+
if params and not set(list(params)).issubset(Balance.filters_array):
2324+
raise HyperwalletException('Invalid filter')
2325+
22722326
response = self.apiClient.doGet(
22732327
self.__buildUrl(
22742328
'programs',
@@ -2679,6 +2733,9 @@ def listWebhookNotifications(self,
26792733
An array of Webhooks.
26802734
'''
26812735

2736+
if params and not set(list(params)).issubset(Webhook.filters_array):
2737+
raise HyperwalletException('Invalid filter')
2738+
26822739
response = self.apiClient.doGet('webhook-notifications', params)
26832740

26842741
return [Webhook(x) for x in response.get('data', [])]
@@ -2992,9 +3049,6 @@ def listTransferRefunds(self,
29923049
if not transferToken:
29933050
raise HyperwalletException('transferToken is required')
29943051

2995-
if params and not TransferRefunds.filter_array >= params.keys():
2996-
raise HyperwalletException('Invalid filter')
2997-
29983052
response = self.apiClient.doGet(
29993053
self.__buildUrl(
30003054
'transfers',
@@ -3094,7 +3148,7 @@ def listTransferStatusTransitions(self,
30943148
if not transferToken:
30953149
raise HyperwalletException('transferToken is required')
30963150

3097-
if params and not StatusTransition.filter_array >= params.keys():
3151+
if params and not set(list(params)).issubset(StatusTransition.filters_array):
30983152
raise HyperwalletException('Invalid filter')
30993153

31003154
response = self.apiClient.doGet(

hyperwallet/models.py

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

73+
filters_array = {'clientUserId', 'email', 'programToken', 'status', 'verificationStatus'}
74+
7375
def __init__(self, data):
7476
'''
7577
Create a new User with the provided attributes.
@@ -199,6 +201,8 @@ class BankAccount(TransferMethod):
199201
A dictionary containing the attributes for the Bank Account.
200202
'''
201203

204+
filters_array = {'type', 'status'}
205+
202206
def __init__(self, data):
203207
'''
204208
Create a new Bank Account with the provided attributes.
@@ -280,6 +284,8 @@ class BankCard(TransferMethod):
280284
A dictionary containing the attributes for the Bank Card.
281285
'''
282286

287+
filters_array = {'status'}
288+
283289
def __init__(self, data):
284290
'''
285291
Create a new Bank Card with the provided attributes.
@@ -314,6 +320,8 @@ class PrepaidCard(TransferMethod):
314320
A dictionary containing the attributes for the Prepaid Card.
315321
'''
316322

323+
filters_array = {'status'}
324+
317325
def __init__(self, data):
318326
'''
319327
Create a new Prepaid Card with the provided attributes.
@@ -347,6 +355,8 @@ class PaperCheck(TransferMethod):
347355
A dictionary containing the attributes for the Paper Check.
348356
'''
349357

358+
filters_array = {'status'}
359+
350360
def __init__(self, data):
351361
'''
352362
Create a new Paper Check with the provided attributes.
@@ -404,6 +414,8 @@ class Transfer(HyperwalletModel):
404414
A dictionary containing the attributes for the Transfer.
405415
'''
406416

417+
filters_array = {'clientTransferId', 'sourceToken', 'destinationToken'}
418+
407419
def __init__(self, data):
408420
'''
409421
Create a new Transfer with the provided attributes.
@@ -448,6 +460,8 @@ class PayPalAccount(TransferMethod):
448460
A dictionary containing the attributes for the PayPal Account.
449461
'''
450462

463+
filters_array = {'status'}
464+
451465
def __init__(self, data):
452466
'''
453467
Create a new PayPal Account with the provided attributes.
@@ -506,6 +520,8 @@ class Payment(HyperwalletModel):
506520
A dictionary containing the attributes for the Payment.
507521
'''
508522

523+
filters_array = {'clientPaymentId', 'releaseOn'}
524+
509525
def __init__(self, data):
510526
'''
511527
Create a new Payment with the provided attributes.
@@ -548,6 +564,8 @@ class Balance(HyperwalletModel):
548564
A dictionary containing the attributes for the Balance.
549565
'''
550566

567+
filters_array = {'currency'}
568+
551569
def __init__(self, data):
552570
'''
553571
Create a new Balance with the provided attributes.
@@ -682,7 +700,7 @@ class StatusTransition(HyperwalletModel):
682700
A dictionary containing the attributes for the Status Transition.
683701
'''
684702

685-
filter_array = {'transition'}
703+
filters_array = {'transition'}
686704

687705
def __init__(self, data):
688706
'''
@@ -760,6 +778,8 @@ class Webhook(HyperwalletModel):
760778
A dictionary containing the attributes for the Webhook.
761779
'''
762780

781+
filters_array = {'programToken'}
782+
763783
def __init__(self, data):
764784
'''
765785
Create a new Webhook with the provided attributes.
@@ -819,8 +839,6 @@ class TransferRefunds(HyperwalletModel):
819839
A dictionary containing the attributes for the Transfer Refunds.
820840
'''
821841

822-
filter_array = {'clientRefundId', 'sourceToken', 'destinationTokens'}
823-
824842
def __init__(self, data):
825843
'''
826844
Create a new Transfer Refunds with the provided attributes.

0 commit comments

Comments
 (0)