payrex-python 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {payrex_python-0.1.3 → payrex_python-0.1.4}/PKG-INFO +1 -1
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex/http_client.py +30 -21
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex_python.egg-info/PKG-INFO +1 -1
- {payrex_python-0.1.3 → payrex_python-0.1.4}/setup.py +1 -1
- {payrex_python-0.1.3 → payrex_python-0.1.4}/LICENSE +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/README.md +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex/__init__.py +1 -1
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex/api_resource.py +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex/client.py +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex/config.py +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex/error.py +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex_python.egg-info/SOURCES.txt +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex_python.egg-info/dependency_links.txt +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex_python.egg-info/requires.txt +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/payrex_python.egg-info/top_level.txt +0 -0
- {payrex_python-0.1.3 → payrex_python-0.1.4}/setup.cfg +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import requests
|
|
3
|
+
import re
|
|
3
4
|
|
|
4
5
|
from urllib.parse import urlencode
|
|
5
6
|
|
|
@@ -19,10 +20,18 @@ class HttpClient:
|
|
|
19
20
|
|
|
20
21
|
auth = requests.auth.HTTPBasicAuth(self.api_key, '')
|
|
21
22
|
|
|
22
|
-
headers = {
|
|
23
|
+
headers = {
|
|
24
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
25
|
+
}
|
|
23
26
|
|
|
24
|
-
if method.lower() in ['post', 'put']:
|
|
25
|
-
data =
|
|
27
|
+
if method.lower() in ['post', 'put', 'delete']:
|
|
28
|
+
data = re.sub(
|
|
29
|
+
r'%5B[\d+]%5D',
|
|
30
|
+
'%5B%5D',
|
|
31
|
+
urlencode(
|
|
32
|
+
self._http_build_query(params)
|
|
33
|
+
)
|
|
34
|
+
)
|
|
26
35
|
else:
|
|
27
36
|
data = None
|
|
28
37
|
|
|
@@ -36,6 +45,24 @@ class HttpClient:
|
|
|
36
45
|
|
|
37
46
|
return ApiResource(response.json())
|
|
38
47
|
|
|
48
|
+
def _http_build_query(self, params, parent_key='', sep='&'):
|
|
49
|
+
items = []
|
|
50
|
+
|
|
51
|
+
for key, value in params.items():
|
|
52
|
+
new_key = f"{parent_key}[{key}]" if parent_key else key
|
|
53
|
+
if isinstance(value, dict):
|
|
54
|
+
items.extend(self._http_build_query(value, new_key, sep=sep).items())
|
|
55
|
+
elif isinstance(value, list):
|
|
56
|
+
for i, v in enumerate(value):
|
|
57
|
+
if isinstance(v, dict):
|
|
58
|
+
items.extend(self._http_build_query(v, f"{new_key}[{i}]", sep=sep).items())
|
|
59
|
+
else:
|
|
60
|
+
items.append((f"{new_key}[{i}]", v))
|
|
61
|
+
else:
|
|
62
|
+
items.append((new_key, value))
|
|
63
|
+
|
|
64
|
+
return dict(items)
|
|
65
|
+
|
|
39
66
|
def _handle_error(self, response):
|
|
40
67
|
try:
|
|
41
68
|
json_response_body = response.json()
|
|
@@ -50,21 +77,3 @@ class HttpClient:
|
|
|
50
77
|
raise ResourceNotFoundException(json_response_body)
|
|
51
78
|
else:
|
|
52
79
|
raise BaseException(json_response_body)
|
|
53
|
-
|
|
54
|
-
def _encode_params(self, params):
|
|
55
|
-
encoded_params = {}
|
|
56
|
-
for key, value in params.items():
|
|
57
|
-
if isinstance(value, list):
|
|
58
|
-
for item in value:
|
|
59
|
-
encoded_params.setdefault(f'{key}[]', []).append(item)
|
|
60
|
-
elif isinstance(value, dict):
|
|
61
|
-
for k, v in value.items():
|
|
62
|
-
if isinstance(v, dict):
|
|
63
|
-
for nk, nv in v.items():
|
|
64
|
-
encoded_params.setdefault(f'{key}[{k}][{nk}]', []).append(nv)
|
|
65
|
-
else:
|
|
66
|
-
encoded_params.setdefault(f'{key}[{k}]', []).append(v)
|
|
67
|
-
else:
|
|
68
|
-
encoded_params[key] = value
|
|
69
|
-
|
|
70
|
-
return urlencode(encoded_params, doseq=True)
|
|
File without changes
|
|
File without changes
|
|
@@ -10,11 +10,11 @@ from payrex.exceptions.value_unexpected_exception import ValueUnexpectedExceptio
|
|
|
10
10
|
|
|
11
11
|
from payrex.http_client import HttpClient
|
|
12
12
|
|
|
13
|
+
from payrex.entities.payment_intent_entity import PaymentIntentEntity
|
|
13
14
|
from payrex.entities.checkout_session_entity import CheckoutSessionEntity
|
|
14
15
|
from payrex.entities.event_entity import EventEntity
|
|
15
16
|
from payrex.entities.listing_entity import ListingEntity
|
|
16
17
|
from payrex.entities.merchant_entity import MerchantEntity
|
|
17
|
-
from payrex.entities.payment_intent_entity import PaymentIntentEntity
|
|
18
18
|
from payrex.entities.payment_method_entity import PaymentMethodEntity
|
|
19
19
|
from payrex.entities.refund_entity import RefundEntity
|
|
20
20
|
from payrex.entities.webhook_entity import WebhookEntity
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|