vtexpy 0.0.0b9__py3-none-any.whl → 0.0.0b10__py3-none-any.whl
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.
- vtex/_api/base.py +22 -45
- vtex/_api/catalog.py +6 -6
- vtex/_api/checkout.py +1 -1
- vtex/_api/custom.py +29 -2
- vtex/_api/license_manager.py +1 -1
- vtex/_api/logistics.py +7 -7
- vtex/_api/master_data.py +1 -1
- vtex/_api/orders.py +4 -4
- vtex/_api/payments_gateway.py +8 -8
- vtex/_api/promotions_and_taxes.py +13 -3
- vtex/_utils.py +29 -1
- vtex/_vtex.py +43 -32
- {vtexpy-0.0.0b9.dist-info → vtexpy-0.0.0b10.dist-info}/METADATA +6 -4
- vtexpy-0.0.0b10.dist-info/RECORD +26 -0
- vtexpy-0.0.0b9.dist-info/RECORD +0 -26
- {vtexpy-0.0.0b9.dist-info → vtexpy-0.0.0b10.dist-info}/LICENSE +0 -0
- {vtexpy-0.0.0b9.dist-info → vtexpy-0.0.0b10.dist-info}/WHEEL +0 -0
vtex/_api/base.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from http import HTTPStatus
|
|
2
2
|
from json import JSONDecodeError
|
|
3
|
-
from logging import WARNING
|
|
3
|
+
from logging import WARNING
|
|
4
4
|
from typing import Any, Type, Union, cast
|
|
5
5
|
from urllib.parse import urljoin
|
|
6
6
|
|
|
@@ -33,6 +33,7 @@ from .._exceptions import VTEXRequestError, VTEXResponseError
|
|
|
33
33
|
from .._logging import get_logger, log_before_retry
|
|
34
34
|
from .._types import HTTPMethodType
|
|
35
35
|
from .._utils import redact_headers, to_snake_case, to_snake_case_deep
|
|
36
|
+
from .._vtex import VTEX
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
class BaseAPI:
|
|
@@ -40,15 +41,11 @@ class BaseAPI:
|
|
|
40
41
|
Base client for VTEX API.
|
|
41
42
|
"""
|
|
42
43
|
|
|
43
|
-
def __init__(
|
|
44
|
-
self
|
|
45
|
-
|
|
46
|
-
logger: Union[Logger, None] = None,
|
|
47
|
-
) -> None:
|
|
48
|
-
self._config = config or Config()
|
|
49
|
-
self._logger = get_logger(
|
|
44
|
+
def __init__(self, client: VTEX) -> None:
|
|
45
|
+
self.client = client
|
|
46
|
+
self.logger = get_logger(
|
|
50
47
|
name=to_snake_case(type(self).__name__),
|
|
51
|
-
parent=logger,
|
|
48
|
+
parent=self.client.logger,
|
|
52
49
|
)
|
|
53
50
|
|
|
54
51
|
def _request(
|
|
@@ -66,14 +63,18 @@ class BaseAPI:
|
|
|
66
63
|
config: Union[Config, None] = None,
|
|
67
64
|
response_class: Union[Type[VTEXResponseType], None] = None,
|
|
68
65
|
) -> VTEXResponseType:
|
|
69
|
-
request_config = self.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
environment
|
|
73
|
-
endpoint
|
|
66
|
+
request_config = config or self.client.config
|
|
67
|
+
|
|
68
|
+
url = urljoin(
|
|
69
|
+
f"https://{request_config.get_account_name()}.{environment}.com.br",
|
|
70
|
+
endpoint,
|
|
74
71
|
)
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
|
|
73
|
+
headers = Headers(headers=headers)
|
|
74
|
+
headers[APP_KEY_HEADER] = request_config.get_app_key()
|
|
75
|
+
headers[APP_TOKEN_HEADER] = request_config.get_app_token()
|
|
76
|
+
headers["Content-Type"] = "application/json; charset=utf-8"
|
|
77
|
+
headers["Accept"] = "application/json"
|
|
77
78
|
|
|
78
79
|
@retry(
|
|
79
80
|
stop=stop_after_attempt(
|
|
@@ -86,7 +87,7 @@ class BaseAPI:
|
|
|
86
87
|
),
|
|
87
88
|
retry=retry_if_exception_type(exception_types=HTTPError),
|
|
88
89
|
before_sleep=(
|
|
89
|
-
log_before_retry(logger=self.
|
|
90
|
+
log_before_retry(logger=self.logger, log_level=WARNING)
|
|
90
91
|
if request_config.get_retry_logs()
|
|
91
92
|
else None
|
|
92
93
|
),
|
|
@@ -110,7 +111,7 @@ class BaseAPI:
|
|
|
110
111
|
redact_headers(dict(response.request.headers)),
|
|
111
112
|
)
|
|
112
113
|
response.headers = Headers(redact_headers(dict(response.headers)))
|
|
113
|
-
if response.status_code in
|
|
114
|
+
if response.status_code in request_config.get_retry_statuses():
|
|
114
115
|
response.raise_for_status()
|
|
115
116
|
|
|
116
117
|
return response
|
|
@@ -129,7 +130,7 @@ class BaseAPI:
|
|
|
129
130
|
"headers": headers,
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
self.
|
|
133
|
+
self.logger.error(str(exception), extra=details, exc_info=True)
|
|
133
134
|
|
|
134
135
|
raise VTEXRequestError(**details) from None # type: ignore[arg-type]
|
|
135
136
|
|
|
@@ -140,30 +141,6 @@ class BaseAPI:
|
|
|
140
141
|
(response_class or VTEXResponse).factory(response),
|
|
141
142
|
)
|
|
142
143
|
|
|
143
|
-
def _get_config(self, config: Union[Config, None]) -> Config:
|
|
144
|
-
return config or self._config
|
|
145
|
-
|
|
146
|
-
def _get_url(self, config: Config, environment: str, endpoint: str) -> str:
|
|
147
|
-
return urljoin(
|
|
148
|
-
f"https://{config.get_account_name()}.{environment}.com.br",
|
|
149
|
-
endpoint,
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
def _get_headers(
|
|
153
|
-
self,
|
|
154
|
-
config: Config,
|
|
155
|
-
headers: Union[HeaderTypes, None] = None,
|
|
156
|
-
) -> Headers:
|
|
157
|
-
request_headers = Headers(headers=headers)
|
|
158
|
-
|
|
159
|
-
request_headers[APP_KEY_HEADER] = config.get_app_key()
|
|
160
|
-
request_headers[APP_TOKEN_HEADER] = config.get_app_token()
|
|
161
|
-
|
|
162
|
-
request_headers["Content-Type"] = "application/json; charset=utf-8"
|
|
163
|
-
request_headers["Accept"] = "application/json"
|
|
164
|
-
|
|
165
|
-
return request_headers
|
|
166
|
-
|
|
167
144
|
def _raise_from_response(self, response: Response, config: Config) -> None:
|
|
168
145
|
if response.is_error and config.get_raise_for_status():
|
|
169
146
|
try:
|
|
@@ -182,8 +159,8 @@ class BaseAPI:
|
|
|
182
159
|
)
|
|
183
160
|
|
|
184
161
|
if response.is_server_error:
|
|
185
|
-
self.
|
|
162
|
+
self.logger.error(data, extra=error.to_dict())
|
|
186
163
|
else:
|
|
187
|
-
self.
|
|
164
|
+
self.logger.warning(data, extra=error.to_dict())
|
|
188
165
|
|
|
189
166
|
raise error from None
|
vtex/_api/catalog.py
CHANGED
|
@@ -39,7 +39,7 @@ class CatalogAPI(BaseAPI):
|
|
|
39
39
|
"sellerType": seller_type,
|
|
40
40
|
"isBetterScope": is_better_scope,
|
|
41
41
|
}),
|
|
42
|
-
config=self.
|
|
42
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
43
43
|
response_class=VTEXListResponse,
|
|
44
44
|
)
|
|
45
45
|
|
|
@@ -60,7 +60,7 @@ class CatalogAPI(BaseAPI):
|
|
|
60
60
|
MIN_PAGE_SIZE,
|
|
61
61
|
),
|
|
62
62
|
},
|
|
63
|
-
config=self.
|
|
63
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
64
64
|
response_class=VTEXListResponse,
|
|
65
65
|
)
|
|
66
66
|
|
|
@@ -69,7 +69,7 @@ class CatalogAPI(BaseAPI):
|
|
|
69
69
|
method="GET",
|
|
70
70
|
environment=self.ENVIRONMENT,
|
|
71
71
|
endpoint=f"/api/catalog_system/pvt/sku/stockkeepingunitbyid/{sku_id}",
|
|
72
|
-
config=self.
|
|
72
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
73
73
|
response_class=VTEXResponse,
|
|
74
74
|
)
|
|
75
75
|
|
|
@@ -90,7 +90,7 @@ class CatalogAPI(BaseAPI):
|
|
|
90
90
|
MIN_PAGE_SIZE,
|
|
91
91
|
),
|
|
92
92
|
},
|
|
93
|
-
config=self.
|
|
93
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
94
94
|
response_class=VTEXPaginatedListResponse,
|
|
95
95
|
)
|
|
96
96
|
|
|
@@ -103,7 +103,7 @@ class CatalogAPI(BaseAPI):
|
|
|
103
103
|
method="GET",
|
|
104
104
|
environment=self.ENVIRONMENT,
|
|
105
105
|
endpoint=f"/api/catalog_system/pub/category/tree/{levels}",
|
|
106
|
-
config=self.
|
|
106
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
107
107
|
response_class=VTEXResponse,
|
|
108
108
|
)
|
|
109
109
|
|
|
@@ -112,6 +112,6 @@ class CatalogAPI(BaseAPI):
|
|
|
112
112
|
method="GET",
|
|
113
113
|
environment=self.ENVIRONMENT,
|
|
114
114
|
endpoint=f"/api/catalog/pvt/category/{category_id}",
|
|
115
|
-
config=self.
|
|
115
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
116
116
|
response_class=VTEXResponse,
|
|
117
117
|
)
|
vtex/_api/checkout.py
CHANGED
vtex/_api/custom.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Any, List, Type, Union
|
|
2
3
|
|
|
3
4
|
from httpx._types import (
|
|
4
5
|
CookieTypes,
|
|
@@ -11,6 +12,7 @@ from httpx._types import (
|
|
|
11
12
|
|
|
12
13
|
from .._dto import VTEXResponseType
|
|
13
14
|
from .._types import HTTPMethodType
|
|
15
|
+
from .._utils import to_datetime
|
|
14
16
|
from .base import BaseAPI
|
|
15
17
|
|
|
16
18
|
|
|
@@ -46,6 +48,31 @@ class CustomAPI(BaseAPI):
|
|
|
46
48
|
data=data,
|
|
47
49
|
content=content,
|
|
48
50
|
files=files,
|
|
49
|
-
config=self.
|
|
51
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
50
52
|
response_class=response_class,
|
|
51
53
|
)
|
|
54
|
+
|
|
55
|
+
def get_account_name(self) -> str:
|
|
56
|
+
return self.client.license_manager.get_account().data["account_name"]
|
|
57
|
+
|
|
58
|
+
def get_account_creation_date(self) -> datetime:
|
|
59
|
+
return to_datetime(
|
|
60
|
+
self.client.license_manager.get_account().data["creation_date"],
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def get_main_seller(self) -> str:
|
|
64
|
+
return "1"
|
|
65
|
+
|
|
66
|
+
def get_market_place_sellers(self) -> List[str]:
|
|
67
|
+
return [
|
|
68
|
+
seller["seller_id"]
|
|
69
|
+
for seller in self.client.catalog.list_sellers(seller_type=1).items
|
|
70
|
+
if seller["seller_id"] != "1"
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
def get_franchise_sellers(self) -> List[str]:
|
|
74
|
+
return [
|
|
75
|
+
seller["seller_id"]
|
|
76
|
+
for seller in
|
|
77
|
+
self.client.catalog.list_sellers(seller_type=2).items
|
|
78
|
+
]
|
vtex/_api/license_manager.py
CHANGED
vtex/_api/logistics.py
CHANGED
|
@@ -38,7 +38,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
38
38
|
MIN_PAGE_SIZE,
|
|
39
39
|
),
|
|
40
40
|
},
|
|
41
|
-
config=self.
|
|
41
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
42
42
|
response_class=VTEXPaginatedListResponse,
|
|
43
43
|
)
|
|
44
44
|
|
|
@@ -51,7 +51,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
51
51
|
method="GET",
|
|
52
52
|
environment=self.ENVIRONMENT,
|
|
53
53
|
endpoint=f"/api/logistics/pvt/shipping-policies/{shipping_policy_id}",
|
|
54
|
-
config=self.
|
|
54
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
55
55
|
response_class=VTEXResponse,
|
|
56
56
|
)
|
|
57
57
|
|
|
@@ -72,7 +72,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
72
72
|
MIN_PAGE_SIZE,
|
|
73
73
|
),
|
|
74
74
|
},
|
|
75
|
-
config=self.
|
|
75
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
76
76
|
response_class=VTEXPaginatedListResponse,
|
|
77
77
|
)
|
|
78
78
|
|
|
@@ -85,7 +85,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
85
85
|
method="GET",
|
|
86
86
|
environment=self.ENVIRONMENT,
|
|
87
87
|
endpoint=f"/api/logistics/pvt/configuration/carriers/{carrier_id}",
|
|
88
|
-
config=self.
|
|
88
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
89
89
|
response_class=VTEXResponse,
|
|
90
90
|
)
|
|
91
91
|
|
|
@@ -106,7 +106,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
106
106
|
MIN_PAGE_SIZE,
|
|
107
107
|
),
|
|
108
108
|
},
|
|
109
|
-
config=self.
|
|
109
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
110
110
|
response_class=VTEXPaginatedListResponse,
|
|
111
111
|
)
|
|
112
112
|
|
|
@@ -115,7 +115,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
115
115
|
method="GET",
|
|
116
116
|
environment=self.ENVIRONMENT,
|
|
117
117
|
endpoint=f"/api/logistics/pvt/configuration/docks/{dock_id}",
|
|
118
|
-
config=self.
|
|
118
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
119
119
|
response_class=VTEXResponse,
|
|
120
120
|
)
|
|
121
121
|
|
|
@@ -124,6 +124,6 @@ class LogisticsAPI(BaseAPI):
|
|
|
124
124
|
method="GET",
|
|
125
125
|
environment=self.ENVIRONMENT,
|
|
126
126
|
endpoint=f"/api/logistics/pvt/inventory/skus/{sku_id}",
|
|
127
|
-
config=self.
|
|
127
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
128
128
|
response_class=VTEXResponse,
|
|
129
129
|
)
|
vtex/_api/master_data.py
CHANGED
|
@@ -57,6 +57,6 @@ class MasterDataAPI(BaseAPI):
|
|
|
57
57
|
headers={
|
|
58
58
|
"REST-Range": f"resources={(page - 1) * page_size}-{page * page_size}",
|
|
59
59
|
},
|
|
60
|
-
config=self.
|
|
60
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
61
61
|
response_class=VTEXPaginatedListResponse,
|
|
62
62
|
)
|
vtex/_api/orders.py
CHANGED
|
@@ -83,7 +83,7 @@ class OrdersAPI(BaseAPI):
|
|
|
83
83
|
environment=self.ENVIRONMENT,
|
|
84
84
|
endpoint="/api/oms/pvt/orders/",
|
|
85
85
|
params=params,
|
|
86
|
-
config=self.
|
|
86
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
87
87
|
response_class=VTEXPaginatedListResponse,
|
|
88
88
|
)
|
|
89
89
|
|
|
@@ -98,7 +98,7 @@ class OrdersAPI(BaseAPI):
|
|
|
98
98
|
method="GET",
|
|
99
99
|
environment=self.ENVIRONMENT,
|
|
100
100
|
endpoint=f"/api/oms/pvt/orders/{order_id}",
|
|
101
|
-
config=self.
|
|
101
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
102
102
|
response_class=VTEXResponse,
|
|
103
103
|
)
|
|
104
104
|
|
|
@@ -117,7 +117,7 @@ class OrdersAPI(BaseAPI):
|
|
|
117
117
|
MIN_PAGE_SIZE,
|
|
118
118
|
),
|
|
119
119
|
},
|
|
120
|
-
config=self.
|
|
120
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
121
121
|
response_class=VTEXListResponse,
|
|
122
122
|
)
|
|
123
123
|
|
|
@@ -141,6 +141,6 @@ class OrdersAPI(BaseAPI):
|
|
|
141
141
|
environment=self.ENVIRONMENT,
|
|
142
142
|
endpoint="/api/orders/feed/",
|
|
143
143
|
json={"handles": handles},
|
|
144
|
-
config=self.
|
|
144
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
145
145
|
response_class=VTEXResponse,
|
|
146
146
|
)
|
vtex/_api/payments_gateway.py
CHANGED
|
@@ -17,7 +17,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
17
17
|
method="GET",
|
|
18
18
|
environment=self.ENVIRONMENT,
|
|
19
19
|
endpoint=f"/api/pvt/transactions/{transaction_id}",
|
|
20
|
-
config=self.
|
|
20
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
21
21
|
response_class=VTEXResponse,
|
|
22
22
|
)
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
30
30
|
method="GET",
|
|
31
31
|
environment=self.ENVIRONMENT,
|
|
32
32
|
endpoint=f"/api/pvt/transactions/{transaction_id}/interactions",
|
|
33
|
-
config=self.
|
|
33
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
34
34
|
response_class=VTEXListResponse,
|
|
35
35
|
)
|
|
36
36
|
|
|
@@ -43,7 +43,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
43
43
|
method="GET",
|
|
44
44
|
environment=self.ENVIRONMENT,
|
|
45
45
|
endpoint=f"/api/pvt/transactions/{transaction_id}/payments",
|
|
46
|
-
config=self.
|
|
46
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
47
47
|
response_class=VTEXListResponse,
|
|
48
48
|
)
|
|
49
49
|
|
|
@@ -57,7 +57,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
57
57
|
method="GET",
|
|
58
58
|
environment=self.ENVIRONMENT,
|
|
59
59
|
endpoint=f"/api/pvt/transactions/{transaction_id}/payments/{payment_id}",
|
|
60
|
-
config=self.
|
|
60
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
61
61
|
response_class=VTEXResponse,
|
|
62
62
|
)
|
|
63
63
|
|
|
@@ -70,7 +70,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
70
70
|
method="GET",
|
|
71
71
|
environment=self.ENVIRONMENT,
|
|
72
72
|
endpoint=f"/api/pvt/transactions/{transaction_id}/capabilities",
|
|
73
|
-
config=self.
|
|
73
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
74
74
|
response_class=VTEXResponse,
|
|
75
75
|
)
|
|
76
76
|
|
|
@@ -83,7 +83,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
83
83
|
method="GET",
|
|
84
84
|
environment=self.ENVIRONMENT,
|
|
85
85
|
endpoint=f"/api/pvt/transactions/{transaction_id}/cancellations",
|
|
86
|
-
config=self.
|
|
86
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
87
87
|
response_class=VTEXResponse,
|
|
88
88
|
)
|
|
89
89
|
|
|
@@ -96,7 +96,7 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
96
96
|
method="GET",
|
|
97
97
|
environment=self.ENVIRONMENT,
|
|
98
98
|
endpoint=f"/api/pvt/transactions/{transaction_id}/refunds",
|
|
99
|
-
config=self.
|
|
99
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
100
100
|
response_class=VTEXResponse,
|
|
101
101
|
)
|
|
102
102
|
|
|
@@ -109,6 +109,6 @@ class PaymentsGatewayAPI(BaseAPI):
|
|
|
109
109
|
method="GET",
|
|
110
110
|
environment=self.ENVIRONMENT,
|
|
111
111
|
endpoint=f"/api/pvt/transactions/{transaction_id}/settlements",
|
|
112
|
-
config=self.
|
|
112
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
113
113
|
response_class=VTEXResponse,
|
|
114
114
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
+
from .. import VTEXListResponse
|
|
3
4
|
from .._dto import VTEXResponse
|
|
4
5
|
from .base import BaseAPI
|
|
5
6
|
|
|
@@ -12,12 +13,21 @@ class PromotionsAndTaxesAPI(BaseAPI):
|
|
|
12
13
|
|
|
13
14
|
ENVIRONMENT = "vtexcommercestable"
|
|
14
15
|
|
|
16
|
+
def list_archived_promotions(self, **kwargs: Any) -> VTEXListResponse:
|
|
17
|
+
return self._request(
|
|
18
|
+
method="GET",
|
|
19
|
+
environment=self.ENVIRONMENT,
|
|
20
|
+
endpoint="api/rnb/pvt/archive/benefits/calculatorconfiguration",
|
|
21
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
22
|
+
response_class=VTEXListResponse,
|
|
23
|
+
)
|
|
24
|
+
|
|
15
25
|
def list_promotions(self, **kwargs: Any) -> VTEXResponse:
|
|
16
26
|
return self._request(
|
|
17
27
|
method="GET",
|
|
18
28
|
environment=self.ENVIRONMENT,
|
|
19
29
|
endpoint="api/rnb/pvt/benefits/calculatorconfiguration",
|
|
20
|
-
config=self.
|
|
30
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
21
31
|
response_class=VTEXResponse,
|
|
22
32
|
)
|
|
23
33
|
|
|
@@ -26,7 +36,7 @@ class PromotionsAndTaxesAPI(BaseAPI):
|
|
|
26
36
|
method="GET",
|
|
27
37
|
environment=self.ENVIRONMENT,
|
|
28
38
|
endpoint="api/rnb/pvt/taxes/calculatorconfiguration",
|
|
29
|
-
config=self.
|
|
39
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
30
40
|
response_class=VTEXResponse,
|
|
31
41
|
)
|
|
32
42
|
|
|
@@ -39,6 +49,6 @@ class PromotionsAndTaxesAPI(BaseAPI):
|
|
|
39
49
|
method="GET",
|
|
40
50
|
environment=self.ENVIRONMENT,
|
|
41
51
|
endpoint=f"/api/rnb/pvt/calculatorconfiguration/{promotion_or_tax_id}",
|
|
42
|
-
config=self.
|
|
52
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
43
53
|
response_class=VTEXResponse,
|
|
44
54
|
)
|
vtex/_utils.py
CHANGED
|
@@ -3,6 +3,8 @@ from re import compile
|
|
|
3
3
|
from typing import Any, Dict, Mapping, Union
|
|
4
4
|
from uuid import UUID
|
|
5
5
|
|
|
6
|
+
from dateutil.parser import parse as parse_datetime
|
|
7
|
+
from dateutil.tz import tzoffset
|
|
6
8
|
from distutils.util import strtobool
|
|
7
9
|
|
|
8
10
|
from ._constants import APP_KEY_HEADER, APP_TOKEN_HEADER
|
|
@@ -82,8 +84,34 @@ def redact_headers(headers: Mapping[str, str]) -> Dict[str, str]:
|
|
|
82
84
|
return redacted_headers
|
|
83
85
|
|
|
84
86
|
|
|
87
|
+
def to_tzinfo(tz: Union[tzinfo, int, None] = None) -> tzinfo:
|
|
88
|
+
if isinstance(tz, tzinfo):
|
|
89
|
+
return tz
|
|
90
|
+
|
|
91
|
+
if isinstance(tz, int):
|
|
92
|
+
return tzoffset(None, tz)
|
|
93
|
+
|
|
94
|
+
return timezone.utc
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def to_datetime(
|
|
98
|
+
value: Union[datetime, str],
|
|
99
|
+
use_tz: bool = True,
|
|
100
|
+
tz: Union[tzinfo, int, None] = None,
|
|
101
|
+
) -> datetime:
|
|
102
|
+
value_as_datetime = value if isinstance(value, datetime) else parse_datetime(value)
|
|
103
|
+
|
|
104
|
+
if not use_tz:
|
|
105
|
+
return value_as_datetime.replace(tzinfo=None)
|
|
106
|
+
|
|
107
|
+
if value_as_datetime.tzinfo and tz is None:
|
|
108
|
+
return value_as_datetime
|
|
109
|
+
|
|
110
|
+
return value_as_datetime.replace(tzinfo=to_tzinfo(tz))
|
|
111
|
+
|
|
112
|
+
|
|
85
113
|
def now(use_tz: bool = True, tz: Union[tzinfo, None] = None) -> datetime:
|
|
86
|
-
return datetime.now((tz
|
|
114
|
+
return datetime.now(to_tzinfo(tz) if use_tz else None)
|
|
87
115
|
|
|
88
116
|
|
|
89
117
|
def three_years_ago(use_tz: bool = True, tz: Union[tzinfo, None] = None) -> datetime:
|
vtex/_vtex.py
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
from functools import cached_property
|
|
2
|
-
from typing import Union
|
|
2
|
+
from typing import TYPE_CHECKING, Union
|
|
3
3
|
|
|
4
|
-
from ._api import (
|
|
5
|
-
CatalogAPI,
|
|
6
|
-
CheckoutAPI,
|
|
7
|
-
CustomAPI,
|
|
8
|
-
LicenseManagerAPI,
|
|
9
|
-
LogisticsAPI,
|
|
10
|
-
MasterDataAPI,
|
|
11
|
-
OrdersAPI,
|
|
12
|
-
PaymentsGatewayAPI,
|
|
13
|
-
PromotionsAndTaxesAPI,
|
|
14
|
-
)
|
|
15
4
|
from ._config import Config # type: ignore[attr-defined]
|
|
16
5
|
from ._logging import CLIENT_LOGGER
|
|
17
6
|
from ._sentinels import UNDEFINED, UndefinedSentinel
|
|
18
7
|
from ._types import IterableType
|
|
19
8
|
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ._api import (
|
|
11
|
+
CatalogAPI,
|
|
12
|
+
CheckoutAPI,
|
|
13
|
+
CustomAPI,
|
|
14
|
+
LicenseManagerAPI,
|
|
15
|
+
LogisticsAPI,
|
|
16
|
+
MasterDataAPI,
|
|
17
|
+
OrdersAPI,
|
|
18
|
+
PaymentsGatewayAPI,
|
|
19
|
+
PromotionsAndTaxesAPI,
|
|
20
|
+
)
|
|
21
|
+
|
|
20
22
|
|
|
21
23
|
class VTEX:
|
|
22
24
|
"""
|
|
@@ -38,8 +40,8 @@ class VTEX:
|
|
|
38
40
|
retry_logs: Union[bool, UndefinedSentinel] = UNDEFINED,
|
|
39
41
|
raise_for_status: Union[bool, UndefinedSentinel] = UNDEFINED,
|
|
40
42
|
) -> None:
|
|
41
|
-
self.
|
|
42
|
-
self.
|
|
43
|
+
self.logger = CLIENT_LOGGER
|
|
44
|
+
self.config = Config(
|
|
43
45
|
account_name=account_name,
|
|
44
46
|
app_key=app_key,
|
|
45
47
|
app_token=app_token,
|
|
@@ -54,37 +56,46 @@ class VTEX:
|
|
|
54
56
|
)
|
|
55
57
|
|
|
56
58
|
@cached_property
|
|
57
|
-
def custom(self) -> CustomAPI:
|
|
58
|
-
|
|
59
|
+
def custom(self) -> "CustomAPI":
|
|
60
|
+
from ._api import CustomAPI
|
|
61
|
+
return CustomAPI(client=self)
|
|
59
62
|
|
|
60
63
|
@cached_property
|
|
61
|
-
def catalog(self) -> CatalogAPI:
|
|
62
|
-
|
|
64
|
+
def catalog(self) -> "CatalogAPI":
|
|
65
|
+
from ._api import CatalogAPI
|
|
66
|
+
return CatalogAPI(client=self)
|
|
63
67
|
|
|
64
68
|
@cached_property
|
|
65
|
-
def checkout(self) -> CheckoutAPI:
|
|
66
|
-
|
|
69
|
+
def checkout(self) -> "CheckoutAPI":
|
|
70
|
+
from ._api import CheckoutAPI
|
|
71
|
+
return CheckoutAPI(client=self)
|
|
67
72
|
|
|
68
73
|
@cached_property
|
|
69
|
-
def license_manager(self) -> LicenseManagerAPI:
|
|
70
|
-
|
|
74
|
+
def license_manager(self) -> "LicenseManagerAPI":
|
|
75
|
+
from ._api import LicenseManagerAPI
|
|
76
|
+
return LicenseManagerAPI(client=self)
|
|
71
77
|
|
|
72
78
|
@cached_property
|
|
73
|
-
def logistics(self) -> LogisticsAPI:
|
|
74
|
-
|
|
79
|
+
def logistics(self) -> "LogisticsAPI":
|
|
80
|
+
from ._api import LogisticsAPI
|
|
81
|
+
return LogisticsAPI(client=self)
|
|
75
82
|
|
|
76
83
|
@cached_property
|
|
77
|
-
def master_data(self) -> MasterDataAPI:
|
|
78
|
-
|
|
84
|
+
def master_data(self) -> "MasterDataAPI":
|
|
85
|
+
from ._api import MasterDataAPI
|
|
86
|
+
return MasterDataAPI(client=self)
|
|
79
87
|
|
|
80
88
|
@cached_property
|
|
81
|
-
def orders(self) -> OrdersAPI:
|
|
82
|
-
|
|
89
|
+
def orders(self) -> "OrdersAPI":
|
|
90
|
+
from ._api import OrdersAPI
|
|
91
|
+
return OrdersAPI(client=self)
|
|
83
92
|
|
|
84
93
|
@cached_property
|
|
85
|
-
def payments_gateway(self) -> PaymentsGatewayAPI:
|
|
86
|
-
|
|
94
|
+
def payments_gateway(self) -> "PaymentsGatewayAPI":
|
|
95
|
+
from ._api import PaymentsGatewayAPI
|
|
96
|
+
return PaymentsGatewayAPI(client=self)
|
|
87
97
|
|
|
88
98
|
@cached_property
|
|
89
|
-
def promotions_and_taxes(self) -> PromotionsAndTaxesAPI:
|
|
90
|
-
|
|
99
|
+
def promotions_and_taxes(self) -> "PromotionsAndTaxesAPI":
|
|
100
|
+
from ._api import PromotionsAndTaxesAPI
|
|
101
|
+
return PromotionsAndTaxesAPI(client=self)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vtexpy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.0b10
|
|
4
4
|
Summary: Unofficial Python SDK for VTEX API
|
|
5
5
|
Home-page: https://github.com/lvieirajr/vtex-python
|
|
6
6
|
License: MIT
|
|
@@ -26,6 +26,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Classifier: Typing :: Typed
|
|
28
28
|
Requires-Dist: httpx (>=0.26,<1.0)
|
|
29
|
+
Requires-Dist: python-dateutil (>=2.9,<3.0)
|
|
29
30
|
Requires-Dist: tenacity (>=8.3,<10.0)
|
|
30
31
|
Project-URL: Documentation, https://github.com/lvieirajr/vtex-python
|
|
31
32
|
Project-URL: Repository, https://github.com/lvieirajr/vtex-python
|
|
@@ -53,9 +54,10 @@ API.
|
|
|
53
54
|
|
|
54
55
|
#### Requirements
|
|
55
56
|
|
|
56
|
-
- Python >= 3.9, <3.14
|
|
57
|
-
- httpx >= 0.26, <1.0
|
|
58
|
-
-
|
|
57
|
+
- Python >= 3.9, < 3.14
|
|
58
|
+
- httpx >= 0.26, < 1.0
|
|
59
|
+
- python-dateutil >= 2.9, < 3.0
|
|
60
|
+
- tenacity >= 8.3, < 10.0
|
|
59
61
|
|
|
60
62
|
#### Installation
|
|
61
63
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
vtex/__init__.py,sha256=MHSWXYxS1emq7iO1iIwmMtrg_rbCROdHO20mra0gdEs,594
|
|
2
|
+
vtex/_api/__init__.py,sha256=V4n0SQrqCcVFWtm8J7jbmwIRI9mCSURwdD_8uHGueAI,353
|
|
3
|
+
vtex/_api/base.py,sha256=32PJNl0En-YtrMU06VjvuTXlJgpO72gs1qFQ_RUYIWE,5554
|
|
4
|
+
vtex/_api/catalog.py,sha256=o2J1FNXtqFMhNbU2mZDNy-fAunkMg1BZWx5piaPHTWk,3998
|
|
5
|
+
vtex/_api/checkout.py,sha256=jywcSnI5nZMycUPpglNzTS5eUOlYkmHD9yvR6MvyvFw,1685
|
|
6
|
+
vtex/_api/custom.py,sha256=9p1x_vxUkj84vORWRqrdxXMOdtN1GxCFBZJ2TAPT1CU,2318
|
|
7
|
+
vtex/_api/license_manager.py,sha256=HlPrD_sSqsWCaCPDwZ0YbuzeHxXFFXRWQwnbyWBGdEg,598
|
|
8
|
+
vtex/_api/logistics.py,sha256=3qPkcyurN5vnsBLmvDd7AMlNYYY-dj7jRMr27Mna5EM,4314
|
|
9
|
+
vtex/_api/master_data.py,sha256=LHe0uSx2FYmj5vzcyHIX2HKKd3qnfJqI8W83f1Oq1bs,2067
|
|
10
|
+
vtex/_api/orders.py,sha256=tns1ExwNEQnKbpByeaQT-iy0asiR3rExCSuCCQAtzo0,4994
|
|
11
|
+
vtex/_api/payments_gateway.py,sha256=_CI_R3rtYxc8w-jfEpYdIuS4juXY3CjPG-W4DrogdVI,3616
|
|
12
|
+
vtex/_api/promotions_and_taxes.py,sha256=vG7p4izxdCLJCr3xL4x5sKOgUhN7TjOHrFobM33bvKI,1805
|
|
13
|
+
vtex/_config.py,sha256=pOtyvpPF7hFTsdd4jb3oTTuBrkIlpE0cWF4-hqLBmpM,16866
|
|
14
|
+
vtex/_constants.py,sha256=BV6BRgbYA6_jcp2t_SBXjXgVgg2-iDdJrYYXsXETU_8,1701
|
|
15
|
+
vtex/_dto.py,sha256=N4fgcXCq0D4xVmD6ntG5X9vR_Clfl_F4NVLmDFPddjY,6030
|
|
16
|
+
vtex/_exceptions.py,sha256=8aly7jBClpWKdZoC8SqJrCljeucebYDZNZeSS1nfaOg,2162
|
|
17
|
+
vtex/_logging.py,sha256=66tjBs0KvbU3dB14PdSjhdi0C4RT60GEuMPvOe87j7s,1622
|
|
18
|
+
vtex/_sentinels.py,sha256=HLkYBJVHTx9GoyACPO1SuINaGlU2YiqOPuFXUa7iG8A,1120
|
|
19
|
+
vtex/_types.py,sha256=zx5DLAjaxMeYbvC_Wno7-9UwoLc8j-awkoW2SjhVXAU,675
|
|
20
|
+
vtex/_utils.py,sha256=oqQ0y8_PHmvv4exV9hAZIyS0Nsp8c4BcSXlpEv2KRQE,3522
|
|
21
|
+
vtex/_vtex.py,sha256=qAKeawNvFBqqut6_BT-zoHE1CljVxNYl_YGXw1u46MU,3347
|
|
22
|
+
vtex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
vtexpy-0.0.0b10.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
24
|
+
vtexpy-0.0.0b10.dist-info/METADATA,sha256=iu6RO9ywnR8AVVT5bNK2aJHDHbwk4PO1Px5s4v2m9Iw,2306
|
|
25
|
+
vtexpy-0.0.0b10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
26
|
+
vtexpy-0.0.0b10.dist-info/RECORD,,
|
vtexpy-0.0.0b9.dist-info/RECORD
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
vtex/__init__.py,sha256=MHSWXYxS1emq7iO1iIwmMtrg_rbCROdHO20mra0gdEs,594
|
|
2
|
-
vtex/_api/__init__.py,sha256=V4n0SQrqCcVFWtm8J7jbmwIRI9mCSURwdD_8uHGueAI,353
|
|
3
|
-
vtex/_api/base.py,sha256=lbli3qA7Hd9DdKWllwH08F9kwh_kravwimni7OmzlPU,6262
|
|
4
|
-
vtex/_api/catalog.py,sha256=P3qgJhwWsPiHl__kR_E8sLZmVVfwjJvd9Hli59dJ0gk,3962
|
|
5
|
-
vtex/_api/checkout.py,sha256=TRQElMkrYJNs0nnLsOSnEnBHYX5CRzYWUM_8KUdk3Io,1679
|
|
6
|
-
vtex/_api/custom.py,sha256=p39hg7K6007SIisJeSj61xYVRUul_CsovWPVzJf6Kjw,1461
|
|
7
|
-
vtex/_api/license_manager.py,sha256=8pg1Zh-lyurB1zyO0ynKasR1cvz4AyQ0t3Efb-VLRjo,592
|
|
8
|
-
vtex/_api/logistics.py,sha256=HYpeZp_mTD04fb7CU1xkp4mSTW5qg9quotD7QfJsEnA,4272
|
|
9
|
-
vtex/_api/master_data.py,sha256=3psvAUtTXpdf5nJQX_l_bPbK1WuiHwRS8s4qCOSKO2Q,2061
|
|
10
|
-
vtex/_api/orders.py,sha256=_fr-UAIJNEPGxNIlaDOkTpGwxU5jH9BKlWj1sfu3a7A,4970
|
|
11
|
-
vtex/_api/payments_gateway.py,sha256=eD11czUXiyRMzHdKIWGfuOr-PvhtIkrXMqTUBGSSg2s,3568
|
|
12
|
-
vtex/_api/promotions_and_taxes.py,sha256=-Bs7zwKB26Ky6TaFX9f6z_NZF82Acd6G8s4TGvPe5Pc,1385
|
|
13
|
-
vtex/_config.py,sha256=pOtyvpPF7hFTsdd4jb3oTTuBrkIlpE0cWF4-hqLBmpM,16866
|
|
14
|
-
vtex/_constants.py,sha256=BV6BRgbYA6_jcp2t_SBXjXgVgg2-iDdJrYYXsXETU_8,1701
|
|
15
|
-
vtex/_dto.py,sha256=N4fgcXCq0D4xVmD6ntG5X9vR_Clfl_F4NVLmDFPddjY,6030
|
|
16
|
-
vtex/_exceptions.py,sha256=8aly7jBClpWKdZoC8SqJrCljeucebYDZNZeSS1nfaOg,2162
|
|
17
|
-
vtex/_logging.py,sha256=66tjBs0KvbU3dB14PdSjhdi0C4RT60GEuMPvOe87j7s,1622
|
|
18
|
-
vtex/_sentinels.py,sha256=HLkYBJVHTx9GoyACPO1SuINaGlU2YiqOPuFXUa7iG8A,1120
|
|
19
|
-
vtex/_types.py,sha256=zx5DLAjaxMeYbvC_Wno7-9UwoLc8j-awkoW2SjhVXAU,675
|
|
20
|
-
vtex/_utils.py,sha256=zoknymKx7e5Ih9pOlUtUHkNLT5THFPVaGmxkZ94rMA0,2806
|
|
21
|
-
vtex/_vtex.py,sha256=x7xKWqbNDbJZ2171KG_hwjW2ChcHl2PXluxj-PpjUcA,3151
|
|
22
|
-
vtex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
-
vtexpy-0.0.0b9.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
24
|
-
vtexpy-0.0.0b9.dist-info/METADATA,sha256=R3zgp6-kODw_zGQp4DKC9BgOZTPbcUox4sRW8npxUvs,2226
|
|
25
|
-
vtexpy-0.0.0b9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
26
|
-
vtexpy-0.0.0b9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|