Skip to content

Commit

Permalink
HW Parity PaypalAccount Representation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dvengatesh-pp-dev committed Nov 30, 2022
1 parent 53f7227 commit 645ba10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions hyperwallet/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,8 +1554,8 @@ def createPayPalAccount(self,
if not ('transferMethodCurrency' in data) or not (data['transferMethodCurrency']):
raise HyperwalletException('transferMethodCurrency is required')

if not ('email' in data) or not (data['email']):
raise HyperwalletException('email is required')
if (not ('email' in data) or not (data['email'])) and (not ('accountId' in data) or not (data['accountId'])):
raise HyperwalletException('email/accountId is required')

response = self.apiClient.doPost(
self.__buildUrl('users', userToken, 'paypal-accounts'),
Expand Down
3 changes: 2 additions & 1 deletion hyperwallet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ def __init__(self, data):
super(PayPalAccount, self).__init__(data)

self.defaults = {
'email': None
'email': None,
'accountId': None
}

for (param, default) in self.defaults.items():
Expand Down
15 changes: 14 additions & 1 deletion hyperwallet/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ def test_create_paypal_account_fail_need_email(self):
with self.assertRaises(HyperwalletException) as exc:
self.api.createPayPalAccount('token', paypal_account_data)

self.assertEqual(exc.exception.message, 'email is required')
self.assertEqual(exc.exception.message, 'email/accountId is required')

@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
def test_create_paypal_account_success(self, mock_post):
Expand All @@ -1544,6 +1544,19 @@ def test_create_paypal_account_success(self, mock_post):

self.assertTrue(response.email, paypal_account_data.get('token'))

@mock.patch('hyperwallet.utils.ApiClient._makeRequest')
def test_create_paypal_account_accountId_success(self, mock_post):

paypal_account_data = {
'transferMethodCountry': 'test-transfer-method-country',
'transferMethodCurrency': 'test-transfer-method-currency',
'accountId': 'test-email'
}
mock_post.return_value = paypal_account_data
response = self.api.createPayPalAccount('token', paypal_account_data)

self.assertTrue(response.accountId, paypal_account_data.get('token'))

def test_update_paypal_account_fail_need_user_token(self):

with self.assertRaises(HyperwalletException) as exc:
Expand Down

0 comments on commit 645ba10

Please sign in to comment.