Skip to content

Commit 204eb84

Browse files
Merge pull request #49 from hyperwallet/feature/DTPAYWONE-564-Add-taxVerificationStatus-to-User
DTPAYWONE-564: Add taxVerificationStatus to User class
2 parents 4dc6273 + fa05645 commit 204eb84

5 files changed

Lines changed: 26 additions & 22 deletions

File tree

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A library to manage users, transfer methods and payments through the Hyperwallet
1212
Prerequisites
1313
-------------
1414

15-
Hyperwallet's Python server SDK requires at minimum Python 2.7 and above.
15+
Hyperwallet's Python server SDK requires at minimum Python 3.5 and above.
1616

1717
Installation
1818
------------

hyperwallet/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,7 @@ def __buildUrl(self, *paths):
27652765
return '/'.join(s.strip('/') for s in paths)
27662766

27672767
def setDocumentAndReasonFromResponseHelper(self,
2768-
data=None):
2768+
data=None):
27692769
'''
27702770
Helper to modify dictionary with Document and Reason classes
27712771
@@ -3131,7 +3131,7 @@ def listTransferMethods(self,
31313131

31323132
if not userToken:
31333133
raise HyperwalletException('userToken is required')
3134-
3134+
31353135
if params and not set(list(params)).issubset(TransferMethod.filters_array):
31363136
raise HyperwalletException('Invalid filter')
31373137

hyperwallet/models.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from enum import Enum
55

6+
67
class HyperwalletModel(object):
78
'''
89
The base Hyperwallet Model from which all other models will inherit.
@@ -70,7 +71,7 @@ class User(HyperwalletModel):
7071
A dictionary containing the attributes for the User.
7172
'''
7273

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

7576
def __init__(self, data):
7677
'''
@@ -116,6 +117,7 @@ def __init__(self, data):
116117
'status': None,
117118
'token': None,
118119
'verificationStatus': None,
120+
'taxVerificationStatus': None,
119121
'timeZone': None,
120122
'documents': None
121123
}
@@ -129,6 +131,7 @@ def __repr__(self):
129131
token=self.token
130132
)
131133

134+
132135
class HyperwalletVerificationDocument(HyperwalletModel):
133136
'''
134137
The HyperwalletVerificationDocument Model.
@@ -162,6 +165,7 @@ def __repr__(self):
162165
createdOn=self.createdOn, category=self.category
163166
)
164167

168+
165169
class HyperwalletVerificationDocumentReason(HyperwalletModel):
166170
'''
167171
The HyperwalletVerificationDocumentReason Model.
@@ -190,6 +194,7 @@ def __repr__(self):
190194
name=self.name, description=self.description
191195
)
192196

197+
193198
class RejectReason(Enum):
194199
DOCUMENT_EXPIRED = 0
195200
DOCUMENT_NOT_RELATED_TO_PROFILE = 1
@@ -200,6 +205,7 @@ class RejectReason(Enum):
200205
DOCUMENT_NOT_VALID_WITH_NOTES = 6
201206
DOCUMENT_TYPE_NOT_VALID = 7
202207

208+
203209
class AuthenticationToken(HyperwalletModel):
204210
'''
205211
The AuthenticationToken Model.
@@ -273,7 +279,7 @@ class BankAccount(TransferMethod):
273279
A dictionary containing the attributes for the Bank Account.
274280
'''
275281

276-
filters_array = {'type','status', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
282+
filters_array = {'type', 'status', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
277283

278284
def __init__(self, data):
279285
'''
@@ -486,7 +492,7 @@ class Transfer(HyperwalletModel):
486492
A dictionary containing the attributes for the Transfer.
487493
'''
488494

489-
filters_array = {'clientTransferId','sourceToken','destinationToken', 'createdBefore', 'createdAfter', 'offset', 'limit'}
495+
filters_array = {'clientTransferId', 'sourceToken', 'destinationToken', 'createdBefore', 'createdAfter', 'offset', 'limit'}
490496

491497
def __init__(self, data):
492498
'''
@@ -532,7 +538,7 @@ class PayPalAccount(TransferMethod):
532538
A dictionary containing the attributes for the PayPal Account.
533539
'''
534540

535-
filters_array = {'status', 'type', 'createdOn' , 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
541+
filters_array = {'status', 'type', 'createdOn', 'createdBefore', 'createdAfter', 'sortBy', 'offset', 'limit'}
536542

537543
def __init__(self, data):
538544
'''

hyperwallet/tests/test_api.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def setUp(self):
6464
'currencies': ['USD'],
6565
'type': 'INDIVIDUAL'
6666
}
67-
67+
6868
self.uploadSuccessData = {
6969
'token': 'tkn-12345',
7070
"documents": [{
@@ -84,12 +84,12 @@ def setUp(self):
8484
"status": "INVALID",
8585
"reasons": [
8686
{
87-
"name": "DOCUMENT_CORRECTION_REQUIRED",
88-
"description": "Document requires correction"
87+
"name": "DOCUMENT_CORRECTION_REQUIRED",
88+
"description": "Document requires correction"
8989
},
9090
{
91-
"name": "DOCUMENT_NOT_DECISIVE",
92-
"description": "Decision cannot be made based on document. Alternative document required"
91+
"name": "DOCUMENT_NOT_DECISIVE",
92+
"description": "Decision cannot be made based on document. Alternative document required"
9393
}
9494
],
9595
"createdOn": "2020-11-24T19:05:02"
@@ -220,7 +220,7 @@ def test_list_user_status_transitions_fail_need_params_invalid(self):
220220

221221
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
222222
def test_list_user_status_transitions_params_valid(self, mock_get):
223-
223+
224224
options = {'transition': 'test'}
225225
mock_get.return_value = {'data': [self.data]}
226226
response = self.api.listUserStatusTransitions('token', options)
@@ -810,7 +810,7 @@ def test_list_prepaid_cards_fail_need_params_invalid(self):
810810
self.api.listPrepaidCards('token', options)
811811

812812
self.assertEqual(exc.exception.message, 'Invalid filter')
813-
813+
814814
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
815815
def test_list_prepaid_cards_params_valid(self, mock_get):
816816

@@ -1892,7 +1892,7 @@ def test_list_venmo_accounts_fail_need_params_invalid(self):
18921892
self.api.listVenmoAccounts('token', options)
18931893

18941894
self.assertEqual(exc.exception.message, 'Invalid filter')
1895-
1895+
18961896
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
18971897
def test_list_venmo_accounts_params_valid(self, mock_get):
18981898

@@ -2101,7 +2101,7 @@ def test_get_payment_success(self, mock_get):
21012101
self.assertTrue(response.token, self.data.get('token'))
21022102

21032103
def test_list_payments_fail_need_params_invalid(self):
2104-
2104+
21052105
options = {'currency': 'test', 'email': 'test'}
21062106
with self.assertRaises(HyperwalletException) as exc:
21072107
self.api.listPayments(options)
@@ -2585,7 +2585,6 @@ def test_list_transfer_method_configurations_params_valid(self, mock_get):
25852585

25862586
self.assertTrue(response[0].type, self.configuration.get('type'))
25872587

2588-
25892588
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
25902589
def test_list_transfer_method_configurations_success(self, mock_get):
25912590

@@ -2677,7 +2676,6 @@ def test_uploadDocumentsForUserAndParse_success(self, mock_put):
26772676
self.assertEqual(response.token, self.uploadSuccessData.get('token'))
26782677
self.assertEqual(response.documents[0].type, self.uploadSuccessData.get("documents")[0].type)
26792678

2680-
26812679
@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
26822680
def test_uploadDocumentsForUserAndParseRejection_success(self, mock_put):
26832681

@@ -2869,7 +2867,7 @@ def test_list_transfer_status_transitions_fail_need_params_invalid(self):
28692867

28702868
options = {'transition': 'test', 'token': 'test'}
28712869
with self.assertRaises(HyperwalletException) as exc:
2872-
self.api.listTransferStatusTransitions('token',options)
2870+
self.api.listTransferStatusTransitions('token', options)
28732871

28742872
self.assertEqual(exc.exception.message, 'Invalid filter')
28752873

@@ -2957,7 +2955,7 @@ def test_list_transfer_methods_fail_need_params_invalid(self):
29572955

29582956
options = {'type': 'test', 'token': 'test'}
29592957
with self.assertRaises(HyperwalletException) as exc:
2960-
self.api.listTransferMethods('token',options)
2958+
self.api.listTransferMethods('token', options)
29612959

29622960
self.assertEqual(exc.exception.message, 'Invalid filter')
29632961

hyperwallet/utils/apiclient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _makeRequest(self,
116116
}]
117117
})
118118

119-
if response.status_code is 204:
119+
if response.status_code == 204:
120120
return {}
121121

122122
self.__checkResponseHeaderContentType(response)
@@ -211,7 +211,7 @@ def __checkResponseHeaderContentType(self, response):
211211

212212
contentType = response.headers['Content-Type']
213213
expectedContentType = 'application/jose+json' if self.encrypted else 'application/json'
214-
invalidContentType = response.status_code is not 204 and contentType is not None and expectedContentType not in contentType
214+
invalidContentType = response.status_code != 204 and contentType is not None and expectedContentType not in contentType
215215
if (invalidContentType):
216216
raise HyperwalletAPIException('Invalid Content-Type specified in Response Header')
217217

0 commit comments

Comments
 (0)