Skip to content

Commit acd7403

Browse files
committed
Stop success return when message or response in json
1 parent 9a020f3 commit acd7403

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

paddle/paddle.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ def request(
122122
if 'response' in response_json and response_json['response'] is not None: # NOQA: E501
123123
return response_json['response']
124124

125+
if 'message' in response_json and response_json['message'] is not None:
126+
return response_json['message']
127+
125128
# Response is only {"success": True}
126-
return response_json['success']
129+
if len(response_json.keys()) == 1 and 'success' in response_json:
130+
return response_json['success']
131+
132+
return response_json
127133

128134
def get(self, url, **kwargs):
129135
kwargs['url'] = url

tests/test_user_history.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ def test_get_user_history_with_vendor_id(unset_vendor_id): # NOQA: F811
1010
vendor_id = 11
1111
paddle = Paddle(vendor_id=vendor_id)
1212
response = paddle.get_user_history(email=email, vendor_id=vendor_id)
13-
assert len(response.keys()) == 2
14-
assert response['message'] == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.' # NOQA: E501
15-
assert response['success'] is True
13+
assert response == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.' # NOQA: E501
1614

1715

1816
def test_get_user_history_with_vendor_id_env_var(paddle_client): # NOQA: F811
1917
email = 'test@example.com'
2018
response = paddle_client.get_user_history(email=email)
21-
assert len(response.keys()) == 2
22-
assert response['message'] == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.' # NOQA: E501
23-
assert response['success'] is True
19+
assert response == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.' # NOQA: E501
2420

2521

2622
def test_get_user_history_with_product_id(paddle_client): # NOQA: F811
@@ -39,6 +35,4 @@ def test_get_user_history_missing_vendoer_id_and_product_id(unset_vendor_id): #
3935
vendor_id = 11
4036
paddle = Paddle(vendor_id=vendor_id)
4137
response = paddle.get_user_history(email=email)
42-
assert len(response.keys()) == 2
43-
assert response['message'] == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.' # NOQA: E501
44-
assert response['success'] is True
38+
assert response == 'We\'ve sent details of your past transactions, licenses and downloads to you via email.' # NOQA: E501

0 commit comments

Comments
 (0)