vtexpy 0.0.0b35__tar.gz → 0.0.0b36__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.
Potentially problematic release.
This version of vtexpy might be problematic. Click here for more details.
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/PKG-INFO +1 -2
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/pyproject.toml +1 -2
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/base.py +11 -45
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/orders.py +1 -6
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/payments_gateway.py +0 -6
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_config.py +64 -44
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_constants.py +0 -2
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/LICENSE +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/README.md +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/__init__.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/__init__.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/catalog.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/checkout.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/custom.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/license_manager.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/logistics.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/master_data.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/pricing.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/promotions_and_taxes.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/types/__init__.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/types/catalog.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/types/generic.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_api/types/license_manager.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_dto.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_exceptions.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_logging.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_sentinels.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_types.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_utils.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/_vtex.py +0 -0
- {vtexpy-0.0.0b35 → vtexpy-0.0.0b36}/vtex/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vtexpy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.0b36
|
|
4
4
|
Summary: Unofficial VTEX API's Python SDK
|
|
5
5
|
Home-page: https://github.com/lvieirajr/vtex-python
|
|
6
6
|
License: Apache
|
|
@@ -27,7 +27,6 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
27
27
|
Classifier: Typing :: Typed
|
|
28
28
|
Requires-Dist: cachetools (>=5.0,<6.0)
|
|
29
29
|
Requires-Dist: httpx (>=0.17,<1.0)
|
|
30
|
-
Requires-Dist: limits (>=3.7,<4.0)
|
|
31
30
|
Requires-Dist: pydantic (>=2.0,<3.0)
|
|
32
31
|
Requires-Dist: python-dateutil (>=2.9,<3.0)
|
|
33
32
|
Requires-Dist: tenacity (>=8.0,<10.0)
|
|
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "vtexpy"
|
|
7
7
|
description = "Unofficial VTEX API's Python SDK"
|
|
8
|
-
version = "0.0.
|
|
8
|
+
version = "0.0.0b36"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache"
|
|
11
11
|
authors = [
|
|
@@ -42,7 +42,6 @@ packages = [
|
|
|
42
42
|
python = ">=3.9,<3.14"
|
|
43
43
|
cachetools = {version = ">=5.0,<6.0"}
|
|
44
44
|
httpx = {version = ">=0.17,<1.0"}
|
|
45
|
-
limits = {version = ">=3.7,<4.0"}
|
|
46
45
|
pydantic = {version = ">=2.0,<3.0"}
|
|
47
46
|
python-dateutil = {version = ">=2.9,<3.0"}
|
|
48
47
|
tenacity = {version = ">=8.0,<10.0"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from http import HTTPStatus
|
|
2
2
|
from json import JSONDecodeError
|
|
3
|
-
from time import sleep
|
|
4
3
|
from typing import Any, Type, Union, cast
|
|
5
4
|
|
|
6
5
|
from httpx import (
|
|
@@ -18,7 +17,6 @@ from httpx._types import (
|
|
|
18
17
|
RequestData,
|
|
19
18
|
RequestFiles,
|
|
20
19
|
)
|
|
21
|
-
from limits import RateLimitItem, errors, storage, strategies
|
|
22
20
|
from tenacity import (
|
|
23
21
|
retry,
|
|
24
22
|
retry_if_exception_type,
|
|
@@ -61,8 +59,6 @@ class BaseAPI:
|
|
|
61
59
|
content: Union[RequestContent, None] = None,
|
|
62
60
|
files: Union[RequestFiles, None] = None,
|
|
63
61
|
config: Union[VTEXConfig, None] = None,
|
|
64
|
-
rate_limit: Union[RateLimitItem, None] = None,
|
|
65
|
-
rate_limit_key: Union[str, None] = None,
|
|
66
62
|
response_class: Union[Type[VTEXResponseType], None] = None,
|
|
67
63
|
**kwargs: Any,
|
|
68
64
|
) -> VTEXResponseType:
|
|
@@ -86,19 +82,6 @@ class BaseAPI:
|
|
|
86
82
|
headers["Content-Type"] = "application/json; charset=utf-8"
|
|
87
83
|
headers["Accept"] = "application/json"
|
|
88
84
|
|
|
89
|
-
rate_limiter = (
|
|
90
|
-
None
|
|
91
|
-
if not (
|
|
92
|
-
rate_limit and rate_limit_key and request_config.rate_limit_storage_url
|
|
93
|
-
)
|
|
94
|
-
else strategies.MovingWindowRateLimiter(
|
|
95
|
-
storage.storage_from_string(
|
|
96
|
-
request_config.rate_limit_storage_url,
|
|
97
|
-
wrap_exceptions=True,
|
|
98
|
-
),
|
|
99
|
-
)
|
|
100
|
-
)
|
|
101
|
-
|
|
102
85
|
@retry(
|
|
103
86
|
stop=stop_after_attempt(
|
|
104
87
|
max_attempt_number=request_config.retry_attempts + 1,
|
|
@@ -125,34 +108,17 @@ class BaseAPI:
|
|
|
125
108
|
def send_vtex_request() -> Response:
|
|
126
109
|
with Client(timeout=request_config.timeout) as client:
|
|
127
110
|
with disable_loggers(["httpcore", "httpx"]):
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
response = client.request(
|
|
140
|
-
method.upper(),
|
|
141
|
-
url,
|
|
142
|
-
headers=headers,
|
|
143
|
-
cookies=cookies,
|
|
144
|
-
params=params,
|
|
145
|
-
json=json,
|
|
146
|
-
data=data,
|
|
147
|
-
content=content,
|
|
148
|
-
files=files,
|
|
149
|
-
)
|
|
150
|
-
finally:
|
|
151
|
-
if rate_limit and rate_limit_key and rate_limiter:
|
|
152
|
-
try:
|
|
153
|
-
rate_limiter.hit(rate_limit, rate_limit_key)
|
|
154
|
-
except errors.StorageError:
|
|
155
|
-
pass
|
|
111
|
+
response = client.request(
|
|
112
|
+
method.upper(),
|
|
113
|
+
url,
|
|
114
|
+
headers=headers,
|
|
115
|
+
cookies=cookies,
|
|
116
|
+
params=params,
|
|
117
|
+
json=json,
|
|
118
|
+
data=data,
|
|
119
|
+
content=content,
|
|
120
|
+
files=files,
|
|
121
|
+
)
|
|
156
122
|
|
|
157
123
|
response.request.headers = Headers(
|
|
158
124
|
redact_headers(dict(response.request.headers)),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
from datetime import datetime, timedelta, timezone
|
|
2
2
|
from typing import Any, Dict, List, Union
|
|
3
3
|
|
|
4
|
-
from limits import parse
|
|
5
|
-
|
|
6
4
|
from .._constants import (
|
|
7
5
|
LIST_FEED_ORDERS_MAX_PAGE_SIZE,
|
|
8
6
|
LIST_ORDERS_MAX_PAGE,
|
|
@@ -52,6 +50,7 @@ class OrdersAPI(BaseAPI):
|
|
|
52
50
|
min(page_size, LIST_ORDERS_MAX_PAGE_SIZE),
|
|
53
51
|
MIN_PAGE_SIZE,
|
|
54
52
|
),
|
|
53
|
+
"_stats": 1,
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
if query is not UNDEFINED:
|
|
@@ -88,8 +87,6 @@ class OrdersAPI(BaseAPI):
|
|
|
88
87
|
environment=self.ENVIRONMENT,
|
|
89
88
|
params=params,
|
|
90
89
|
config=self.client.config.with_overrides(**kwargs),
|
|
91
|
-
rate_limit=parse("1000 per minute"),
|
|
92
|
-
rate_limit_key=f"{self.client.config.account_name}:orders",
|
|
93
90
|
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
94
91
|
)
|
|
95
92
|
|
|
@@ -105,8 +102,6 @@ class OrdersAPI(BaseAPI):
|
|
|
105
102
|
endpoint=f"/api/oms/pvt/orders/{order_id}",
|
|
106
103
|
environment=self.ENVIRONMENT,
|
|
107
104
|
config=self.client.config.with_overrides(**kwargs),
|
|
108
|
-
rate_limit=parse("5500 per minute"),
|
|
109
|
-
rate_limit_key=f"{self.client.config.account_name}:orders",
|
|
110
105
|
response_class=VTEXDataResponse[Any],
|
|
111
106
|
)
|
|
112
107
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
from limits import parse
|
|
4
|
-
|
|
5
3
|
from .._dto import VTEXDataResponse, VTEXItemsResponse
|
|
6
4
|
from .base import BaseAPI
|
|
7
5
|
|
|
@@ -37,10 +35,6 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
37
35
|
endpoint=f"/api/pvt/transactions/{transaction_id}/interactions",
|
|
38
36
|
environment=self.ENVIRONMENT,
|
|
39
37
|
config=self.client.config.with_overrides(**kwargs),
|
|
40
|
-
rate_limit=parse("3000 per minute"),
|
|
41
|
-
rate_limit_key=(
|
|
42
|
-
f"{self.client.config.account_name}:transaction_interactions"
|
|
43
|
-
),
|
|
44
38
|
response_class=VTEXItemsResponse[Any, Any],
|
|
45
39
|
)
|
|
46
40
|
|
|
@@ -15,7 +15,6 @@ from ._constants import (
|
|
|
15
15
|
DEFAULT_LOG_5XX,
|
|
16
16
|
DEFAULT_LOG_RETRIES,
|
|
17
17
|
DEFAULT_RAISE_FOR_STATUS_CODE,
|
|
18
|
-
DEFAULT_RATE_LIMIT_STORAGE_URL,
|
|
19
18
|
DEFAULT_RETRY_ATTEMPTS,
|
|
20
19
|
DEFAULT_RETRY_BACKOFF_MAX,
|
|
21
20
|
DEFAULT_RETRY_BACKOFF_MIN,
|
|
@@ -28,7 +27,6 @@ from ._constants import (
|
|
|
28
27
|
LOG_5XX_ENV_VAR,
|
|
29
28
|
LOG_RETRIES_ENV_VAR,
|
|
30
29
|
RAISE_FOR_STATUS_CODE_ENV_VAR,
|
|
31
|
-
RATE_LIMIT_STORAGE_URL_ENV_VAR,
|
|
32
30
|
RETRY_ATTEMPTS_ENV_VAR,
|
|
33
31
|
RETRY_BACKOFF_MAX_ENV_VAR,
|
|
34
32
|
RETRY_BACKOFF_MIN_ENV_VAR,
|
|
@@ -44,27 +42,70 @@ FalseOrLogLevelOrUndefined = Union[FalseOrLogLevel, UndefinedSentinel]
|
|
|
44
42
|
|
|
45
43
|
|
|
46
44
|
class VTEXConfig(BaseModel):
|
|
47
|
-
account_name: str = Field(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
account_name: str = Field( # type: ignore[assignment]
|
|
46
|
+
UNDEFINED,
|
|
47
|
+
validate_default=True,
|
|
48
|
+
)
|
|
49
|
+
app_key: SecretStr = Field( # type: ignore[assignment]
|
|
50
|
+
UNDEFINED,
|
|
51
|
+
validate_default=True,
|
|
52
|
+
)
|
|
53
|
+
app_token: SecretStr = Field( # type: ignore[assignment]
|
|
54
|
+
UNDEFINED,
|
|
55
|
+
validate_default=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
timeout: Union[float, None] = Field( # type: ignore[assignment]
|
|
59
|
+
UNDEFINED,
|
|
60
|
+
validate_default=True,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
retry_attempts: int = Field( # type: ignore[assignment]
|
|
64
|
+
UNDEFINED,
|
|
65
|
+
validate_default=True,
|
|
66
|
+
)
|
|
67
|
+
retry_backoff_min: float = Field( # type: ignore[assignment]
|
|
68
|
+
UNDEFINED,
|
|
69
|
+
validate_default=True,
|
|
70
|
+
)
|
|
71
|
+
retry_backoff_max: float = Field( # type: ignore[assignment]
|
|
72
|
+
UNDEFINED,
|
|
73
|
+
validate_default=True,
|
|
74
|
+
)
|
|
75
|
+
retry_status_codes: List[int] = Field(
|
|
76
|
+
UNDEFINED, # type: ignore[arg-type]
|
|
77
|
+
validate_default=True,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
raise_for_status_code: bool = Field( # type: ignore[assignment]
|
|
81
|
+
UNDEFINED,
|
|
82
|
+
validate_default=True,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
log_retries: FalseOrLogLevel = Field(
|
|
86
|
+
UNDEFINED,
|
|
87
|
+
validate_default=True,
|
|
88
|
+
)
|
|
89
|
+
log_1xx: FalseOrLogLevel = Field(
|
|
90
|
+
UNDEFINED,
|
|
91
|
+
validate_default=True,
|
|
92
|
+
)
|
|
93
|
+
log_2xx: FalseOrLogLevel = Field(
|
|
94
|
+
UNDEFINED,
|
|
95
|
+
validate_default=True,
|
|
96
|
+
)
|
|
97
|
+
log_3xx: FalseOrLogLevel = Field(
|
|
98
|
+
UNDEFINED,
|
|
99
|
+
validate_default=True,
|
|
100
|
+
)
|
|
101
|
+
log_4xx: FalseOrLogLevel = Field(
|
|
102
|
+
UNDEFINED,
|
|
103
|
+
validate_default=True,
|
|
104
|
+
)
|
|
105
|
+
log_5xx: FalseOrLogLevel = Field(
|
|
106
|
+
UNDEFINED,
|
|
107
|
+
validate_default=True,
|
|
108
|
+
)
|
|
68
109
|
|
|
69
110
|
def with_overrides(
|
|
70
111
|
self,
|
|
@@ -77,7 +118,6 @@ class VTEXConfig(BaseModel):
|
|
|
77
118
|
retry_backoff_max: Union[float, int, UndefinedSentinel] = UNDEFINED,
|
|
78
119
|
retry_status_codes: Union[List[int], UndefinedSentinel] = UNDEFINED,
|
|
79
120
|
raise_for_status_code: Union[bool, UndefinedSentinel] = UNDEFINED,
|
|
80
|
-
rate_limit_storage_url: Union[str, UndefinedSentinel] = UNDEFINED,
|
|
81
121
|
log_retries: FalseOrLogLevelOrUndefined = UNDEFINED,
|
|
82
122
|
log_1xx: FalseOrLogLevelOrUndefined = UNDEFINED,
|
|
83
123
|
log_2xx: FalseOrLogLevelOrUndefined = UNDEFINED,
|
|
@@ -98,7 +138,6 @@ class VTEXConfig(BaseModel):
|
|
|
98
138
|
"retry_backoff_max": retry_backoff_max,
|
|
99
139
|
"retry_status_codes": retry_status_codes,
|
|
100
140
|
"raise_for_status_code": raise_for_status_code,
|
|
101
|
-
"rate_limit_storage_url": rate_limit_storage_url,
|
|
102
141
|
"log_retries": log_retries,
|
|
103
142
|
"log_1xx": log_1xx,
|
|
104
143
|
"log_2xx": log_2xx,
|
|
@@ -224,25 +263,6 @@ class VTEXConfig(BaseModel):
|
|
|
224
263
|
|
|
225
264
|
raise cls._prepare_value_error(value, RAISE_FOR_STATUS_CODE_ENV_VAR)
|
|
226
265
|
|
|
227
|
-
@field_validator("rate_limit_storage_url", mode="before")
|
|
228
|
-
@classmethod
|
|
229
|
-
def validate_rate_limit_storage_url(cls, value: Any) -> Union[str, None]:
|
|
230
|
-
if isinstance(value, UndefinedSentinel):
|
|
231
|
-
value = getenv(
|
|
232
|
-
RATE_LIMIT_STORAGE_URL_ENV_VAR,
|
|
233
|
-
DEFAULT_RATE_LIMIT_STORAGE_URL,
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
if value is None:
|
|
237
|
-
return None
|
|
238
|
-
elif isinstance(value, str):
|
|
239
|
-
if value.lower() in {"", "none", "null"}:
|
|
240
|
-
return None
|
|
241
|
-
|
|
242
|
-
return value
|
|
243
|
-
|
|
244
|
-
raise cls._prepare_value_error(value, RATE_LIMIT_STORAGE_URL_ENV_VAR)
|
|
245
|
-
|
|
246
266
|
@field_validator("log_retries", mode="before")
|
|
247
267
|
@classmethod
|
|
248
268
|
def validate_log_retries(cls, value: Any) -> FalseOrLogLevel:
|
|
@@ -20,7 +20,6 @@ RETRY_BACKOFF_MIN_ENV_VAR = "VTEX_RETRY_BACKOFF_MIN"
|
|
|
20
20
|
RETRY_BACKOFF_MAX_ENV_VAR = "VTEX_RETRY_BACKOFF_MAX"
|
|
21
21
|
RETRY_STATUS_CODES_ENV_VAR = "VTEX_RETRY_STATUS_CODES"
|
|
22
22
|
RAISE_FOR_STATUS_CODE_ENV_VAR = "VTEX_RAISE_FOR_STATUS_CODE"
|
|
23
|
-
RATE_LIMIT_STORAGE_URL_ENV_VAR = "VTEX_RATE_LIMIT_STORAGE_URL"
|
|
24
23
|
LOG_RETRIES_ENV_VAR = "VTEX_LOG_RETRIES"
|
|
25
24
|
LOG_1XX_ENV_VAR = "VTEX_LOG_1XX"
|
|
26
25
|
LOG_2XX_ENV_VAR = "VTEX_LOG_2XX"
|
|
@@ -47,7 +46,6 @@ DEFAULT_RETRY_STATUS_CODES = [
|
|
|
47
46
|
525,
|
|
48
47
|
]
|
|
49
48
|
DEFAULT_RAISE_FOR_STATUS_CODE = True
|
|
50
|
-
DEFAULT_RATE_LIMIT_STORAGE_URL = None
|
|
51
49
|
DEFAULT_LOG_RETRIES = WARNING
|
|
52
50
|
DEFAULT_LOG_1XX = INFO
|
|
53
51
|
DEFAULT_LOG_2XX = INFO
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|