vtexpy 0.0.0b16__py3-none-any.whl → 0.0.0b18__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.
- vtex/__init__.py +2 -0
- vtex/_api/base.py +62 -39
- vtex/_api/catalog.py +26 -14
- vtex/_api/checkout.py +5 -6
- vtex/_api/custom.py +23 -14
- vtex/_api/license_manager.py +1 -1
- vtex/_api/logistics.py +14 -15
- vtex/_api/master_data.py +5 -5
- vtex/_api/orders.py +9 -9
- vtex/_api/payments_gateway.py +16 -17
- vtex/_api/promotions_and_taxes.py +8 -9
- vtex/_api/types/catalog.py +21 -0
- vtex/_api/types/generic.py +4 -4
- vtex/_api/types/license_manager.py +13 -7
- vtex/_config.py +251 -391
- vtex/_constants.py +18 -6
- vtex/_dto.py +22 -17
- vtex/_logging.py +28 -6
- vtex/_types.py +18 -3
- vtex/_utils.py +16 -20
- vtex/_vtex.py +4 -30
- {vtexpy-0.0.0b16.dist-info → vtexpy-0.0.0b18.dist-info}/METADATA +31 -26
- vtexpy-0.0.0b18.dist-info/RECORD +30 -0
- vtexpy-0.0.0b16.dist-info/RECORD +0 -29
- {vtexpy-0.0.0b16.dist-info → vtexpy-0.0.0b18.dist-info}/LICENSE +0 -0
- {vtexpy-0.0.0b16.dist-info → vtexpy-0.0.0b18.dist-info}/WHEEL +0 -0
vtex/__init__.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from . import _constants as VTEXConstants # noqa: N812
|
|
2
|
+
from ._config import VTEXConfig
|
|
2
3
|
from ._dto import (
|
|
3
4
|
VTEXCartItem,
|
|
4
5
|
VTEXDataResponse,
|
|
@@ -12,6 +13,7 @@ from ._vtex import VTEX
|
|
|
12
13
|
__all__ = [
|
|
13
14
|
"VTEX",
|
|
14
15
|
"VTEXCartItem",
|
|
16
|
+
"VTEXConfig",
|
|
15
17
|
"VTEXConstants",
|
|
16
18
|
"VTEXError",
|
|
17
19
|
"VTEXDataResponse",
|
vtex/_api/base.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from http import HTTPStatus
|
|
2
2
|
from json import JSONDecodeError
|
|
3
|
-
from logging import WARNING
|
|
4
3
|
from typing import Any, Type, Union, cast
|
|
5
4
|
from urllib.parse import urljoin
|
|
6
5
|
|
|
@@ -26,11 +25,11 @@ from tenacity import (
|
|
|
26
25
|
wait_exponential,
|
|
27
26
|
)
|
|
28
27
|
|
|
29
|
-
from .._config import
|
|
28
|
+
from .._config import VTEXConfig
|
|
30
29
|
from .._constants import APP_KEY_HEADER, APP_TOKEN_HEADER
|
|
31
30
|
from .._dto import VTEXDataResponse, VTEXResponseType
|
|
32
31
|
from .._exceptions import VTEXRequestError, VTEXResponseError
|
|
33
|
-
from .._logging import get_logger, log_before_retry
|
|
32
|
+
from .._logging import disable_loggers, get_logger, log_before_retry
|
|
34
33
|
from .._types import HTTPMethodType
|
|
35
34
|
from .._utils import redact_headers, to_snake_case, to_snake_case_deep
|
|
36
35
|
from .._vtex import VTEX
|
|
@@ -60,58 +59,89 @@ class BaseAPI:
|
|
|
60
59
|
data: Union[RequestData, None] = None,
|
|
61
60
|
content: Union[RequestContent, None] = None,
|
|
62
61
|
files: Union[RequestFiles, None] = None,
|
|
63
|
-
config: Union[
|
|
62
|
+
config: Union[VTEXConfig, None] = None,
|
|
64
63
|
response_class: Union[Type[VTEXResponseType], None] = None,
|
|
64
|
+
**kwargs: Any,
|
|
65
65
|
) -> VTEXResponseType:
|
|
66
|
-
request_config = config or self.client.config
|
|
66
|
+
request_config = (config or self.client.config).with_overrides(**kwargs)
|
|
67
67
|
|
|
68
68
|
url = urljoin(
|
|
69
|
-
f"https://{request_config.
|
|
69
|
+
f"https://{request_config.account_name}.{environment}.com.br",
|
|
70
70
|
endpoint,
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
headers = Headers(headers=headers)
|
|
74
|
-
headers[APP_KEY_HEADER] = request_config.
|
|
75
|
-
headers[APP_TOKEN_HEADER] = request_config.
|
|
74
|
+
headers[APP_KEY_HEADER] = request_config.app_key.get_secret_value()
|
|
75
|
+
headers[APP_TOKEN_HEADER] = request_config.app_token.get_secret_value()
|
|
76
76
|
headers["Content-Type"] = "application/json; charset=utf-8"
|
|
77
77
|
headers["Accept"] = "application/json"
|
|
78
78
|
|
|
79
79
|
@retry(
|
|
80
80
|
stop=stop_after_attempt(
|
|
81
|
-
max_attempt_number=request_config.
|
|
81
|
+
max_attempt_number=request_config.retry_attempts + 1,
|
|
82
82
|
),
|
|
83
83
|
wait=wait_exponential(
|
|
84
|
-
min=request_config.
|
|
85
|
-
max=request_config.
|
|
86
|
-
exp_base=
|
|
84
|
+
min=request_config.retry_backoff_min,
|
|
85
|
+
max=request_config.retry_backoff_max,
|
|
86
|
+
exp_base=2.0,
|
|
87
87
|
),
|
|
88
|
-
retry=retry_if_exception_type(exception_types=
|
|
88
|
+
retry=retry_if_exception_type(exception_types=HTTPStatusError),
|
|
89
89
|
before_sleep=(
|
|
90
|
-
log_before_retry(
|
|
91
|
-
|
|
90
|
+
log_before_retry(
|
|
91
|
+
logger=self.logger,
|
|
92
|
+
log_level=request_config.log_retries,
|
|
93
|
+
environment=environment,
|
|
94
|
+
endpoint=endpoint,
|
|
95
|
+
account_name=request_config.account_name,
|
|
96
|
+
)
|
|
97
|
+
if request_config.log_retries is not False
|
|
92
98
|
else None
|
|
93
99
|
),
|
|
94
100
|
reraise=True,
|
|
95
101
|
)
|
|
96
102
|
def send_vtex_request() -> Response:
|
|
97
|
-
with Client(timeout=request_config.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
with Client(timeout=request_config.timeout) as client:
|
|
104
|
+
with disable_loggers(["httpcore", "httpx"]):
|
|
105
|
+
response = client.request(
|
|
106
|
+
method.upper(),
|
|
107
|
+
url,
|
|
108
|
+
headers=headers,
|
|
109
|
+
cookies=cookies,
|
|
110
|
+
params=params,
|
|
111
|
+
json=json,
|
|
112
|
+
data=data,
|
|
113
|
+
content=content,
|
|
114
|
+
files=files,
|
|
115
|
+
)
|
|
109
116
|
|
|
110
117
|
response.request.headers = Headers(
|
|
111
118
|
redact_headers(dict(response.request.headers)),
|
|
112
119
|
)
|
|
113
120
|
response.headers = Headers(redact_headers(dict(response.headers)))
|
|
114
|
-
|
|
121
|
+
|
|
122
|
+
for should_log, log_level in [
|
|
123
|
+
(response.is_informational, request_config.log_1xx),
|
|
124
|
+
(response.is_success, request_config.log_2xx),
|
|
125
|
+
(response.is_redirect, request_config.log_3xx),
|
|
126
|
+
(response.is_client_error, request_config.log_4xx),
|
|
127
|
+
(response.is_server_error, request_config.log_5xx),
|
|
128
|
+
]:
|
|
129
|
+
if should_log and log_level:
|
|
130
|
+
self.logger.log(
|
|
131
|
+
log_level,
|
|
132
|
+
f"{response.request.method} {response.request.url} "
|
|
133
|
+
f"{response.status_code} {response.reason_phrase}",
|
|
134
|
+
extra={
|
|
135
|
+
"method": response.request.method,
|
|
136
|
+
"url": response.request.url,
|
|
137
|
+
"status": response.status_code,
|
|
138
|
+
"environment": environment,
|
|
139
|
+
"endpoint": endpoint,
|
|
140
|
+
"account_name": request_config.account_name,
|
|
141
|
+
},
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
if response.status_code in request_config.retry_statuses:
|
|
115
145
|
response.raise_for_status()
|
|
116
146
|
|
|
117
147
|
return response
|
|
@@ -141,14 +171,14 @@ class BaseAPI:
|
|
|
141
171
|
(response_class or VTEXDataResponse).factory(response),
|
|
142
172
|
)
|
|
143
173
|
|
|
144
|
-
def _raise_from_response(self, response: Response, config:
|
|
145
|
-
if response.is_error and config.
|
|
174
|
+
def _raise_from_response(self, response: Response, config: VTEXConfig) -> None:
|
|
175
|
+
if response.is_error and config.raise_for_status:
|
|
146
176
|
try:
|
|
147
177
|
data = to_snake_case_deep(response.json(strict=False))
|
|
148
178
|
except JSONDecodeError:
|
|
149
179
|
data = response.text or HTTPStatus(response.status_code).phrase
|
|
150
180
|
|
|
151
|
-
|
|
181
|
+
raise VTEXResponseError(
|
|
152
182
|
data,
|
|
153
183
|
method=str(response.request.method).upper(),
|
|
154
184
|
url=str(response.request.url),
|
|
@@ -156,11 +186,4 @@ class BaseAPI:
|
|
|
156
186
|
status=response.status_code,
|
|
157
187
|
data=data,
|
|
158
188
|
response_headers=response.headers,
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
if response.is_server_error:
|
|
162
|
-
self.logger.error(data, extra=error.to_dict())
|
|
163
|
-
else:
|
|
164
|
-
self.logger.warning(data, extra=error.to_dict())
|
|
165
|
-
|
|
166
|
-
raise error from None
|
|
189
|
+
) from None
|
vtex/_api/catalog.py
CHANGED
|
@@ -10,9 +10,9 @@ from .._constants import (
|
|
|
10
10
|
)
|
|
11
11
|
from .._dto import VTEXDataResponse, VTEXItemsResponse, VTEXPaginatedItemsResponse
|
|
12
12
|
from .._sentinels import UNDEFINED, UndefinedSentinel
|
|
13
|
-
from ..
|
|
14
|
-
from .._utils import exclude_undefined_values
|
|
13
|
+
from .._utils import omitting_undefined
|
|
15
14
|
from .base import BaseAPI
|
|
15
|
+
from .types.catalog import SalesChannel, Seller
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class CatalogAPI(BaseAPI):
|
|
@@ -29,18 +29,30 @@ class CatalogAPI(BaseAPI):
|
|
|
29
29
|
seller_type: Union[int, UndefinedSentinel] = UNDEFINED,
|
|
30
30
|
is_better_scope: Union[bool, UndefinedSentinel] = UNDEFINED,
|
|
31
31
|
**kwargs: Any,
|
|
32
|
-
) -> VTEXItemsResponse[
|
|
32
|
+
) -> VTEXItemsResponse[List[Seller], Seller]:
|
|
33
33
|
return self._request(
|
|
34
34
|
method="GET",
|
|
35
35
|
environment=self.ENVIRONMENT,
|
|
36
36
|
endpoint="/api/catalog_system/pvt/seller/list",
|
|
37
|
-
params=
|
|
37
|
+
params=omitting_undefined({
|
|
38
38
|
"sc": sales_channel,
|
|
39
39
|
"sellerType": seller_type,
|
|
40
40
|
"isBetterScope": is_better_scope,
|
|
41
41
|
}),
|
|
42
42
|
config=self.client.config.with_overrides(**kwargs),
|
|
43
|
-
response_class=VTEXItemsResponse[
|
|
43
|
+
response_class=VTEXItemsResponse[Any, Any],
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def list_sales_channels(
|
|
47
|
+
self,
|
|
48
|
+
**kwargs: Any,
|
|
49
|
+
) -> VTEXItemsResponse[List[SalesChannel], SalesChannel]:
|
|
50
|
+
return self._request(
|
|
51
|
+
method="GET",
|
|
52
|
+
environment=self.ENVIRONMENT,
|
|
53
|
+
endpoint="/api/catalog_system/pvt/saleschannel/list",
|
|
54
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
55
|
+
response_class=VTEXItemsResponse[Any, Any],
|
|
44
56
|
)
|
|
45
57
|
|
|
46
58
|
def list_sku_ids(
|
|
@@ -68,13 +80,13 @@ class CatalogAPI(BaseAPI):
|
|
|
68
80
|
self,
|
|
69
81
|
sku_id: int,
|
|
70
82
|
**kwargs: Any,
|
|
71
|
-
) -> VTEXDataResponse[
|
|
83
|
+
) -> VTEXDataResponse[Any]:
|
|
72
84
|
return self._request(
|
|
73
85
|
method="GET",
|
|
74
86
|
environment=self.ENVIRONMENT,
|
|
75
87
|
endpoint=f"/api/catalog_system/pvt/sku/stockkeepingunitbyid/{sku_id}",
|
|
76
88
|
config=self.client.config.with_overrides(**kwargs),
|
|
77
|
-
response_class=VTEXDataResponse[
|
|
89
|
+
response_class=VTEXDataResponse[Any],
|
|
78
90
|
)
|
|
79
91
|
|
|
80
92
|
def list_categories(
|
|
@@ -82,7 +94,7 @@ class CatalogAPI(BaseAPI):
|
|
|
82
94
|
page: int = LIST_SKU_IDS_START_PAGE,
|
|
83
95
|
page_size: int = LIST_SKU_IDS_MAX_PAGE_SIZE,
|
|
84
96
|
**kwargs: Any,
|
|
85
|
-
) -> VTEXPaginatedItemsResponse[
|
|
97
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
86
98
|
return self._request(
|
|
87
99
|
method="GET",
|
|
88
100
|
environment=self.ENVIRONMENT,
|
|
@@ -95,31 +107,31 @@ class CatalogAPI(BaseAPI):
|
|
|
95
107
|
),
|
|
96
108
|
},
|
|
97
109
|
config=self.client.config.with_overrides(**kwargs),
|
|
98
|
-
response_class=VTEXPaginatedItemsResponse[
|
|
110
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
99
111
|
)
|
|
100
112
|
|
|
101
113
|
def get_category_tree(
|
|
102
114
|
self,
|
|
103
115
|
levels: int = GET_CATEGORY_TREE_MAX_LEVELS,
|
|
104
116
|
**kwargs: Any,
|
|
105
|
-
) -> VTEXDataResponse[
|
|
117
|
+
) -> VTEXDataResponse[Any]:
|
|
106
118
|
return self._request(
|
|
107
119
|
method="GET",
|
|
108
120
|
environment=self.ENVIRONMENT,
|
|
109
121
|
endpoint=f"/api/catalog_system/pub/category/tree/{levels}",
|
|
110
122
|
config=self.client.config.with_overrides(**kwargs),
|
|
111
|
-
response_class=VTEXDataResponse[
|
|
123
|
+
response_class=VTEXDataResponse[Any],
|
|
112
124
|
)
|
|
113
125
|
|
|
114
126
|
def get_category(
|
|
115
127
|
self,
|
|
116
|
-
category_id:
|
|
128
|
+
category_id: int,
|
|
117
129
|
**kwargs: Any,
|
|
118
|
-
) -> VTEXDataResponse[
|
|
130
|
+
) -> VTEXDataResponse[Any]:
|
|
119
131
|
return self._request(
|
|
120
132
|
method="GET",
|
|
121
133
|
environment=self.ENVIRONMENT,
|
|
122
134
|
endpoint=f"/api/catalog/pvt/category/{category_id}",
|
|
123
135
|
config=self.client.config.with_overrides(**kwargs),
|
|
124
|
-
response_class=VTEXDataResponse[
|
|
136
|
+
response_class=VTEXDataResponse[Any],
|
|
125
137
|
)
|
vtex/_api/checkout.py
CHANGED
|
@@ -2,8 +2,7 @@ from typing import Any, List, Union
|
|
|
2
2
|
|
|
3
3
|
from .._dto import VTEXCartItem, VTEXDataResponse
|
|
4
4
|
from .._sentinels import UNDEFINED, UndefinedSentinel
|
|
5
|
-
from ..
|
|
6
|
-
from .._utils import exclude_undefined_values
|
|
5
|
+
from .._utils import omitting_undefined
|
|
7
6
|
from .base import BaseAPI
|
|
8
7
|
|
|
9
8
|
|
|
@@ -25,22 +24,22 @@ class CheckoutAPI(BaseAPI):
|
|
|
25
24
|
sales_channel: Union[int, UndefinedSentinel] = UNDEFINED,
|
|
26
25
|
individual_shipping_estimates: Union[bool, UndefinedSentinel] = UNDEFINED,
|
|
27
26
|
**kwargs: Any,
|
|
28
|
-
) -> VTEXDataResponse[
|
|
27
|
+
) -> VTEXDataResponse[Any]:
|
|
29
28
|
return self._request(
|
|
30
29
|
method="POST",
|
|
31
30
|
environment=self.ENVIRONMENT,
|
|
32
31
|
endpoint="/api/checkout/pub/orderForms/simulation",
|
|
33
|
-
params=
|
|
32
|
+
params=omitting_undefined({
|
|
34
33
|
"RnbBehavior": rnb_behavior,
|
|
35
34
|
"sc": sales_channel,
|
|
36
35
|
"individualShippingEstimates": individual_shipping_estimates,
|
|
37
36
|
}),
|
|
38
|
-
json=
|
|
37
|
+
json=omitting_undefined({
|
|
39
38
|
"items": [item.to_vtex_cart_item() for item in cart],
|
|
40
39
|
"country": country,
|
|
41
40
|
"postalCode": postal_code,
|
|
42
41
|
"geoCoordinates": geo_coordinates,
|
|
43
42
|
}),
|
|
44
43
|
config=self.client.config.with_overrides(**kwargs),
|
|
45
|
-
response_class=VTEXDataResponse[
|
|
44
|
+
response_class=VTEXDataResponse[Any],
|
|
46
45
|
)
|
vtex/_api/custom.py
CHANGED
|
@@ -10,10 +10,13 @@ from httpx._types import (
|
|
|
10
10
|
RequestFiles,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
+
from .. import VTEXError
|
|
13
14
|
from .._dto import VTEXResponseType
|
|
14
15
|
from .._types import HTTPMethodType
|
|
15
16
|
from .._utils import to_datetime
|
|
16
17
|
from .base import BaseAPI
|
|
18
|
+
from .types.catalog import Seller
|
|
19
|
+
from .types.license_manager import AccountSite
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
class CustomAPI(BaseAPI):
|
|
@@ -55,31 +58,37 @@ class CustomAPI(BaseAPI):
|
|
|
55
58
|
def get_account_name(self) -> str:
|
|
56
59
|
return self.client.license_manager.get_account().data["account_name"]
|
|
57
60
|
|
|
58
|
-
def
|
|
61
|
+
def get_creation_date(self) -> datetime:
|
|
59
62
|
return to_datetime(
|
|
60
63
|
self.client.license_manager.get_account().data["creation_date"],
|
|
61
64
|
)
|
|
62
65
|
|
|
63
|
-
def
|
|
64
|
-
return
|
|
65
|
-
self.client.license_manager.get_account().data["creation_date"],
|
|
66
|
-
)
|
|
66
|
+
def list_sites(self) -> List[AccountSite]:
|
|
67
|
+
return self.client.license_manager.get_account().data["sites"]
|
|
67
68
|
|
|
68
|
-
def get_main_seller(self) ->
|
|
69
|
-
|
|
69
|
+
def get_main_seller(self) -> Seller:
|
|
70
|
+
for seller in self.client.catalog.list_sellers().items:
|
|
71
|
+
if seller["seller_type"] == 1 and seller["seller_id"] == "1":
|
|
72
|
+
return seller
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
raise VTEXError("Could not find main seller")
|
|
75
|
+
|
|
76
|
+
def list_market_place_sellers(
|
|
77
|
+
self,
|
|
78
|
+
include_inactive: bool = False,
|
|
79
|
+
include_main: bool = False,
|
|
80
|
+
) -> List[Seller]:
|
|
72
81
|
return [
|
|
73
|
-
seller
|
|
82
|
+
seller
|
|
74
83
|
for seller in self.client.catalog.list_sellers().items
|
|
75
84
|
if seller["seller_type"] == 1
|
|
76
|
-
and seller["seller_id"] != "1"
|
|
77
|
-
and (seller["is_active"]
|
|
85
|
+
and (include_main or seller["seller_id"] != "1")
|
|
86
|
+
and (include_inactive or seller["is_active"])
|
|
78
87
|
]
|
|
79
88
|
|
|
80
|
-
def
|
|
89
|
+
def list_franchise_sellers(self, include_inactive: bool = False) -> List[Seller]:
|
|
81
90
|
return [
|
|
82
|
-
seller
|
|
91
|
+
seller
|
|
83
92
|
for seller in self.client.catalog.list_sellers().items
|
|
84
|
-
if seller["seller_type"] == 2 and (seller["is_active"]
|
|
93
|
+
if seller["seller_type"] == 2 and (include_inactive or seller["is_active"])
|
|
85
94
|
]
|
vtex/_api/license_manager.py
CHANGED
vtex/_api/logistics.py
CHANGED
|
@@ -10,7 +10,6 @@ from .._constants import (
|
|
|
10
10
|
MIN_PAGE_SIZE,
|
|
11
11
|
)
|
|
12
12
|
from .._dto import VTEXDataResponse, VTEXPaginatedItemsResponse
|
|
13
|
-
from .._types import DictType
|
|
14
13
|
from .base import BaseAPI
|
|
15
14
|
|
|
16
15
|
|
|
@@ -27,7 +26,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
27
26
|
page: int = LIST_SHIPPING_POLICIES_START_PAGE,
|
|
28
27
|
page_size: int = LIST_SHIPPING_POLICIES_MAX_PAGE_SIZE,
|
|
29
28
|
**kwargs: Any,
|
|
30
|
-
) -> VTEXPaginatedItemsResponse[
|
|
29
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
31
30
|
return self._request(
|
|
32
31
|
method="GET",
|
|
33
32
|
environment=self.ENVIRONMENT,
|
|
@@ -40,20 +39,20 @@ class LogisticsAPI(BaseAPI):
|
|
|
40
39
|
),
|
|
41
40
|
},
|
|
42
41
|
config=self.client.config.with_overrides(**kwargs),
|
|
43
|
-
response_class=VTEXPaginatedItemsResponse[
|
|
42
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
44
43
|
)
|
|
45
44
|
|
|
46
45
|
def get_shipping_policy(
|
|
47
46
|
self,
|
|
48
47
|
shipping_policy_id: str,
|
|
49
48
|
**kwargs: Any,
|
|
50
|
-
) -> VTEXDataResponse[
|
|
49
|
+
) -> VTEXDataResponse[Any]:
|
|
51
50
|
return self._request(
|
|
52
51
|
method="GET",
|
|
53
52
|
environment=self.ENVIRONMENT,
|
|
54
53
|
endpoint=f"/api/logistics/pvt/shipping-policies/{shipping_policy_id}",
|
|
55
54
|
config=self.client.config.with_overrides(**kwargs),
|
|
56
|
-
response_class=VTEXDataResponse[
|
|
55
|
+
response_class=VTEXDataResponse[Any],
|
|
57
56
|
)
|
|
58
57
|
|
|
59
58
|
def list_carriers(
|
|
@@ -61,7 +60,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
61
60
|
page: int = LIST_CARRIERS_START_PAGE,
|
|
62
61
|
page_size: int = LIST_CARRIERS_MAX_PAGE_SIZE,
|
|
63
62
|
**kwargs: Any,
|
|
64
|
-
) -> VTEXPaginatedItemsResponse[
|
|
63
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
65
64
|
return self._request(
|
|
66
65
|
method="GET",
|
|
67
66
|
environment=self.ENVIRONMENT,
|
|
@@ -74,20 +73,20 @@ class LogisticsAPI(BaseAPI):
|
|
|
74
73
|
),
|
|
75
74
|
},
|
|
76
75
|
config=self.client.config.with_overrides(**kwargs),
|
|
77
|
-
response_class=VTEXPaginatedItemsResponse[
|
|
76
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
78
77
|
)
|
|
79
78
|
|
|
80
79
|
def get_carrier(
|
|
81
80
|
self,
|
|
82
81
|
carrier_id: str,
|
|
83
82
|
**kwargs: Any,
|
|
84
|
-
) -> VTEXDataResponse[
|
|
83
|
+
) -> VTEXDataResponse[Any]:
|
|
85
84
|
return self._request(
|
|
86
85
|
method="GET",
|
|
87
86
|
environment=self.ENVIRONMENT,
|
|
88
87
|
endpoint=f"/api/logistics/pvt/configuration/carriers/{carrier_id}",
|
|
89
88
|
config=self.client.config.with_overrides(**kwargs),
|
|
90
|
-
response_class=VTEXDataResponse[
|
|
89
|
+
response_class=VTEXDataResponse[Any],
|
|
91
90
|
)
|
|
92
91
|
|
|
93
92
|
def list_docks(
|
|
@@ -95,7 +94,7 @@ class LogisticsAPI(BaseAPI):
|
|
|
95
94
|
page: int = LIST_DOCKS_START_PAGE,
|
|
96
95
|
page_size: int = LIST_DOCKS_MAX_PAGE_SIZE,
|
|
97
96
|
**kwargs: Any,
|
|
98
|
-
) -> VTEXPaginatedItemsResponse[
|
|
97
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
99
98
|
return self._request(
|
|
100
99
|
method="GET",
|
|
101
100
|
environment=self.ENVIRONMENT,
|
|
@@ -108,27 +107,27 @@ class LogisticsAPI(BaseAPI):
|
|
|
108
107
|
),
|
|
109
108
|
},
|
|
110
109
|
config=self.client.config.with_overrides(**kwargs),
|
|
111
|
-
response_class=VTEXPaginatedItemsResponse[
|
|
110
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
112
111
|
)
|
|
113
112
|
|
|
114
|
-
def get_dock(self, dock_id: str, **kwargs: Any) -> VTEXDataResponse[
|
|
113
|
+
def get_dock(self, dock_id: str, **kwargs: Any) -> VTEXDataResponse[Any]:
|
|
115
114
|
return self._request(
|
|
116
115
|
method="GET",
|
|
117
116
|
environment=self.ENVIRONMENT,
|
|
118
117
|
endpoint=f"/api/logistics/pvt/configuration/docks/{dock_id}",
|
|
119
118
|
config=self.client.config.with_overrides(**kwargs),
|
|
120
|
-
response_class=VTEXDataResponse[
|
|
119
|
+
response_class=VTEXDataResponse[Any],
|
|
121
120
|
)
|
|
122
121
|
|
|
123
122
|
def get_sku_inventories(
|
|
124
123
|
self,
|
|
125
124
|
sku_id: str,
|
|
126
125
|
**kwargs: Any,
|
|
127
|
-
) -> VTEXDataResponse[
|
|
126
|
+
) -> VTEXDataResponse[Any]:
|
|
128
127
|
return self._request(
|
|
129
128
|
method="GET",
|
|
130
129
|
environment=self.ENVIRONMENT,
|
|
131
130
|
endpoint=f"/api/logistics/pvt/inventory/skus/{sku_id}",
|
|
132
131
|
config=self.client.config.with_overrides(**kwargs),
|
|
133
|
-
response_class=VTEXDataResponse[
|
|
132
|
+
response_class=VTEXDataResponse[Any],
|
|
134
133
|
)
|
vtex/_api/master_data.py
CHANGED
|
@@ -7,8 +7,8 @@ from .._constants import (
|
|
|
7
7
|
)
|
|
8
8
|
from .._dto import VTEXPaginatedItemsResponse
|
|
9
9
|
from .._sentinels import UNDEFINED, UndefinedSentinel
|
|
10
|
-
from .._types import
|
|
11
|
-
from .._utils import
|
|
10
|
+
from .._types import OrderingDirectionType
|
|
11
|
+
from .._utils import omitting_undefined
|
|
12
12
|
from .base import BaseAPI
|
|
13
13
|
|
|
14
14
|
|
|
@@ -30,7 +30,7 @@ class MasterDataAPI(BaseAPI):
|
|
|
30
30
|
page: int = SEARCH_DOCUMENTS_START_PAGE,
|
|
31
31
|
page_size: int = SEARCH_DOCUMENTS_MAX_PAGE_SIZE,
|
|
32
32
|
**kwargs: Any,
|
|
33
|
-
) -> VTEXPaginatedItemsResponse[
|
|
33
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
34
34
|
params = {
|
|
35
35
|
"_where": where,
|
|
36
36
|
"_sort": f"{order_by_field} {order_by_direction.upper()}",
|
|
@@ -53,10 +53,10 @@ class MasterDataAPI(BaseAPI):
|
|
|
53
53
|
method="GET",
|
|
54
54
|
environment=self.ENVIRONMENT,
|
|
55
55
|
endpoint=f"/api/dataentities/{entity_name}/search",
|
|
56
|
-
params=
|
|
56
|
+
params=omitting_undefined(params),
|
|
57
57
|
headers={
|
|
58
58
|
"REST-Range": f"resources={(page - 1) * page_size}-{page * page_size}",
|
|
59
59
|
},
|
|
60
60
|
config=self.client.config.with_overrides(**kwargs),
|
|
61
|
-
response_class=VTEXPaginatedItemsResponse[
|
|
61
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
62
62
|
)
|
vtex/_api/orders.py
CHANGED
|
@@ -10,7 +10,7 @@ from .._constants import (
|
|
|
10
10
|
)
|
|
11
11
|
from .._dto import VTEXDataResponse, VTEXItemsResponse, VTEXPaginatedItemsResponse
|
|
12
12
|
from .._sentinels import UNDEFINED, UndefinedSentinel
|
|
13
|
-
from .._types import
|
|
13
|
+
from .._types import OrderingDirectionType
|
|
14
14
|
from .._utils import now, three_years_ago
|
|
15
15
|
from .base import BaseAPI
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ class OrdersAPI(BaseAPI):
|
|
|
35
35
|
page: int = LIST_ORDERS_START_PAGE,
|
|
36
36
|
page_size: int = LIST_ORDERS_MAX_PAGE_SIZE,
|
|
37
37
|
**kwargs: Any,
|
|
38
|
-
) -> VTEXPaginatedItemsResponse[
|
|
38
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
39
39
|
if page > LIST_ORDERS_MAX_PAGE:
|
|
40
40
|
raise ValueError("List Orders endpoint can only return up to page 30")
|
|
41
41
|
|
|
@@ -84,7 +84,7 @@ class OrdersAPI(BaseAPI):
|
|
|
84
84
|
endpoint="/api/oms/pvt/orders/",
|
|
85
85
|
params=params,
|
|
86
86
|
config=self.client.config.with_overrides(**kwargs),
|
|
87
|
-
response_class=VTEXPaginatedItemsResponse[
|
|
87
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
88
88
|
)
|
|
89
89
|
|
|
90
90
|
pagination = response.pagination
|
|
@@ -93,20 +93,20 @@ class OrdersAPI(BaseAPI):
|
|
|
93
93
|
|
|
94
94
|
return response
|
|
95
95
|
|
|
96
|
-
def get_order(self, order_id: str, **kwargs: Any) -> VTEXDataResponse[
|
|
96
|
+
def get_order(self, order_id: str, **kwargs: Any) -> VTEXDataResponse[Any]:
|
|
97
97
|
return self._request(
|
|
98
98
|
method="GET",
|
|
99
99
|
environment=self.ENVIRONMENT,
|
|
100
100
|
endpoint=f"/api/oms/pvt/orders/{order_id}",
|
|
101
101
|
config=self.client.config.with_overrides(**kwargs),
|
|
102
|
-
response_class=VTEXDataResponse[
|
|
102
|
+
response_class=VTEXDataResponse[Any],
|
|
103
103
|
)
|
|
104
104
|
|
|
105
105
|
def list_feed_orders(
|
|
106
106
|
self,
|
|
107
107
|
page_size: int = LIST_FEED_ORDERS_MAX_PAGE_SIZE,
|
|
108
108
|
**kwargs: Any,
|
|
109
|
-
) -> VTEXItemsResponse[
|
|
109
|
+
) -> VTEXItemsResponse[Any, Any]:
|
|
110
110
|
return self._request(
|
|
111
111
|
method="GET",
|
|
112
112
|
environment=self.ENVIRONMENT,
|
|
@@ -118,14 +118,14 @@ class OrdersAPI(BaseAPI):
|
|
|
118
118
|
),
|
|
119
119
|
},
|
|
120
120
|
config=self.client.config.with_overrides(**kwargs),
|
|
121
|
-
response_class=VTEXItemsResponse[
|
|
121
|
+
response_class=VTEXItemsResponse[Any, Any],
|
|
122
122
|
)
|
|
123
123
|
|
|
124
124
|
def commit_feed_orders(
|
|
125
125
|
self,
|
|
126
126
|
handles: List[str],
|
|
127
127
|
**kwargs: Any,
|
|
128
|
-
) -> VTEXDataResponse[
|
|
128
|
+
) -> VTEXDataResponse[Any]:
|
|
129
129
|
if not handles:
|
|
130
130
|
raise ValueError(
|
|
131
131
|
"At least one handle must be provided to commit to the feed"
|
|
@@ -142,5 +142,5 @@ class OrdersAPI(BaseAPI):
|
|
|
142
142
|
endpoint="/api/orders/feed/",
|
|
143
143
|
json={"handles": handles},
|
|
144
144
|
config=self.client.config.with_overrides(**kwargs),
|
|
145
|
-
response_class=VTEXDataResponse[
|
|
145
|
+
response_class=VTEXDataResponse[Any],
|
|
146
146
|
)
|