vtexpy 0.0.0b9__tar.gz → 0.0.0b11__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.
Files changed (30) hide show
  1. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/PKG-INFO +22 -4
  2. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/README.md +20 -3
  3. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/pyproject.toml +2 -1
  4. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/__init__.py +6 -6
  5. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/base.py +25 -48
  6. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/catalog.py +29 -21
  7. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/checkout.py +6 -5
  8. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/custom.py +33 -2
  9. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/license_manager.py +5 -4
  10. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/logistics.py +27 -22
  11. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/master_data.py +9 -9
  12. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/orders.py +16 -16
  13. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/payments_gateway.py +30 -25
  14. vtexpy-0.0.0b11/vtex/_api/promotions_and_taxes.py +57 -0
  15. vtexpy-0.0.0b11/vtex/_api/types/license_manager.py +17 -0
  16. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_config.py +6 -7
  17. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_dto.py +58 -65
  18. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_exceptions.py +1 -3
  19. vtexpy-0.0.0b11/vtex/_types.py +22 -0
  20. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_utils.py +30 -3
  21. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_vtex.py +54 -35
  22. vtexpy-0.0.0b11/vtex/py.typed +0 -0
  23. vtexpy-0.0.0b9/vtex/_api/promotions_and_taxes.py +0 -44
  24. vtexpy-0.0.0b9/vtex/_types.py +0 -38
  25. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/LICENSE +0 -0
  26. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_api/__init__.py +0 -0
  27. /vtexpy-0.0.0b9/vtex/py.typed → /vtexpy-0.0.0b11/vtex/_api/types/__init__.py +0 -0
  28. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_constants.py +0 -0
  29. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_logging.py +0 -0
  30. {vtexpy-0.0.0b9 → vtexpy-0.0.0b11}/vtex/_sentinels.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vtexpy
3
- Version: 0.0.0b9
3
+ Version: 0.0.0b11
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
- - tenacity >= 8.3, <10.0
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
 
@@ -65,13 +67,29 @@ pip install vtexpy
65
67
 
66
68
  #### Usage
67
69
 
70
+ If the API you want to call is not yet implemented, feel free to create an issue on the
71
+ VTEXPY Github repository and request it to be added.
72
+
68
73
  ```python
69
74
  from vtex import VTEX
70
75
 
76
+ # 1 - Instantiate the VTEX client for the account you want to access:
71
77
  vtex_client = VTEX(
72
78
  account_name="<ACCOUNT_NAME>",
73
79
  app_key="<APP_KEY>",
74
80
  app_token="<APP_TOKEN>",
75
81
  )
82
+
83
+ # 2 - Call one of the available APIs, e.g.:
84
+ vtex_client.license_manager.get_account()
85
+ vtex_client.catalog.list_sku_ids(page=1, page_size=1000)
86
+ vtex_client.orders.list_orders(page=1, page_size=100)
87
+
88
+ # 3 - If the API you want to call is not yet implemented you can use the `custom` API.
89
+ vtex_client.custom.request(
90
+ method="GET",
91
+ environment="vtexcommercestable",
92
+ endpoint="/api/catalog_system/pvt/commercialcondition/list",
93
+ )
76
94
  ```
77
95
 
@@ -20,9 +20,10 @@ API.
20
20
 
21
21
  #### Requirements
22
22
 
23
- - Python >= 3.9, <3.14
24
- - httpx >= 0.26, <1.0
25
- - tenacity >= 8.3, <10.0
23
+ - Python >= 3.9, < 3.14
24
+ - httpx >= 0.26, < 1.0
25
+ - python-dateutil >= 2.9, < 3.0
26
+ - tenacity >= 8.3, < 10.0
26
27
 
27
28
  #### Installation
28
29
 
@@ -32,12 +33,28 @@ pip install vtexpy
32
33
 
33
34
  #### Usage
34
35
 
36
+ If the API you want to call is not yet implemented, feel free to create an issue on the
37
+ VTEXPY Github repository and request it to be added.
38
+
35
39
  ```python
36
40
  from vtex import VTEX
37
41
 
42
+ # 1 - Instantiate the VTEX client for the account you want to access:
38
43
  vtex_client = VTEX(
39
44
  account_name="<ACCOUNT_NAME>",
40
45
  app_key="<APP_KEY>",
41
46
  app_token="<APP_TOKEN>",
42
47
  )
48
+
49
+ # 2 - Call one of the available APIs, e.g.:
50
+ vtex_client.license_manager.get_account()
51
+ vtex_client.catalog.list_sku_ids(page=1, page_size=1000)
52
+ vtex_client.orders.list_orders(page=1, page_size=100)
53
+
54
+ # 3 - If the API you want to call is not yet implemented you can use the `custom` API.
55
+ vtex_client.custom.request(
56
+ method="GET",
57
+ environment="vtexcommercestable",
58
+ endpoint="/api/catalog_system/pvt/commercialcondition/list",
59
+ )
43
60
  ```
@@ -32,7 +32,7 @@ classifiers = [
32
32
  packages = [
33
33
  {include = "vtex"},
34
34
  ]
35
- version = "0.0.0b9"
35
+ version = "0.0.0b11"
36
36
 
37
37
  [build-system]
38
38
  requires = ["poetry-core"]
@@ -41,6 +41,7 @@ build-backend = "poetry.core.masonry.api"
41
41
  [tool.poetry.dependencies]
42
42
  python = ">=3.9,<3.14"
43
43
  httpx = {version = ">=0.26,<1.0"}
44
+ python-dateutil = {version = ">=2.9,<3.0"}
44
45
  tenacity = {version = ">=8.3,<10.0"}
45
46
 
46
47
  [tool.poetry.group.dev.dependencies]
@@ -1,10 +1,10 @@
1
1
  from . import _constants as VTEXConstants # noqa: N812
2
2
  from ._dto import (
3
3
  VTEXCartItem,
4
- VTEXListResponse,
5
- VTEXPaginatedListResponse,
4
+ VTEXDataResponse,
5
+ VTEXItemsResponse,
6
+ VTEXPaginatedItemsResponse,
6
7
  VTEXResponse,
7
- VTEXScrollListResponse,
8
8
  )
9
9
  from ._exceptions import VTEXError, VTEXRequestError, VTEXResponseError
10
10
  from ._vtex import VTEX
@@ -14,12 +14,12 @@ __all__ = [
14
14
  "VTEXCartItem",
15
15
  "VTEXConstants",
16
16
  "VTEXError",
17
- "VTEXListResponse",
18
- "VTEXPaginatedListResponse",
17
+ "VTEXDataResponse",
18
+ "VTEXItemsResponse",
19
+ "VTEXPaginatedItemsResponse",
19
20
  "VTEXRequestError",
20
21
  "VTEXResponse",
21
22
  "VTEXResponseError",
22
- "VTEXScrollListResponse",
23
23
  ]
24
24
 
25
25
 
@@ -1,6 +1,6 @@
1
1
  from http import HTTPStatus
2
2
  from json import JSONDecodeError
3
- from logging import WARNING, Logger
3
+ from logging import WARNING
4
4
  from typing import Any, Type, Union, cast
5
5
  from urllib.parse import urljoin
6
6
 
@@ -28,27 +28,24 @@ from tenacity import (
28
28
 
29
29
  from .._config import Config # type: ignore[attr-defined]
30
30
  from .._constants import APP_KEY_HEADER, APP_TOKEN_HEADER
31
- from .._dto import VTEXResponse, VTEXResponseType
31
+ from .._dto import VTEXDataResponse, VTEXResponseType
32
32
  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:
39
40
  """
40
- Base client for VTEX API.
41
+ Base client for a VTEX API.
41
42
  """
42
43
 
43
- def __init__(
44
- self,
45
- config: Union[Config, None] = None,
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._get_config(config=config)
70
- url = self._get_url(
71
- config=request_config,
72
- environment=environment,
73
- endpoint=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
- headers = self._get_headers(config=request_config, headers=headers)
76
- retry_statuses = set(request_config.get_retry_statuses())
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._logger, log_level=WARNING)
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 retry_statuses:
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._logger.error(str(exception), extra=details, exc_info=True)
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
 
@@ -137,33 +138,9 @@ class BaseAPI:
137
138
 
138
139
  return cast(
139
140
  VTEXResponseType,
140
- (response_class or VTEXResponse).factory(response),
141
+ (response_class or VTEXDataResponse).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._logger.error(data, extra=error.to_dict())
162
+ self.logger.error(data, extra=error.to_dict())
186
163
  else:
187
- self._logger.warning(data, extra=error.to_dict())
164
+ self.logger.warning(data, extra=error.to_dict())
188
165
 
189
166
  raise error from None
@@ -1,6 +1,5 @@
1
- from typing import Any, Union
1
+ from typing import Any, List, Union
2
2
 
3
- from .. import VTEXPaginatedListResponse
4
3
  from .._constants import (
5
4
  GET_CATEGORY_TREE_MAX_LEVELS,
6
5
  LIST_CATEGORIES_MAX_PAGE_SIZE,
@@ -9,8 +8,9 @@ from .._constants import (
9
8
  LIST_SKU_IDS_START_PAGE,
10
9
  MIN_PAGE_SIZE,
11
10
  )
12
- from .._dto import VTEXListResponse, VTEXResponse
11
+ from .._dto import VTEXDataResponse, VTEXItemsResponse, VTEXPaginatedItemsResponse
13
12
  from .._sentinels import UNDEFINED, UndefinedSentinel
13
+ from .._types import DictType
14
14
  from .._utils import exclude_undefined_values
15
15
  from .base import BaseAPI
16
16
 
@@ -29,7 +29,7 @@ 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
- ) -> VTEXListResponse:
32
+ ) -> VTEXItemsResponse[DictType, DictType]:
33
33
  return self._request(
34
34
  method="GET",
35
35
  environment=self.ENVIRONMENT,
@@ -39,8 +39,8 @@ class CatalogAPI(BaseAPI):
39
39
  "sellerType": seller_type,
40
40
  "isBetterScope": is_better_scope,
41
41
  }),
42
- config=self._config.with_overrides(**kwargs),
43
- response_class=VTEXListResponse,
42
+ config=self.client.config.with_overrides(**kwargs),
43
+ response_class=VTEXItemsResponse[DictType, DictType],
44
44
  )
45
45
 
46
46
  def list_sku_ids(
@@ -48,7 +48,7 @@ class CatalogAPI(BaseAPI):
48
48
  page: int = LIST_SKU_IDS_START_PAGE,
49
49
  page_size: int = LIST_SKU_IDS_MAX_PAGE_SIZE,
50
50
  **kwargs: Any,
51
- ) -> VTEXListResponse:
51
+ ) -> VTEXItemsResponse[List[str], str]:
52
52
  return self._request(
53
53
  method="GET",
54
54
  environment=self.ENVIRONMENT,
@@ -60,17 +60,21 @@ class CatalogAPI(BaseAPI):
60
60
  MIN_PAGE_SIZE,
61
61
  ),
62
62
  },
63
- config=self._config.with_overrides(**kwargs),
64
- response_class=VTEXListResponse,
63
+ config=self.client.config.with_overrides(**kwargs),
64
+ response_class=VTEXItemsResponse[List[str], str],
65
65
  )
66
66
 
67
- def get_sku_with_context(self, sku_id: int, **kwargs: Any) -> VTEXResponse:
67
+ def get_sku_with_context(
68
+ self,
69
+ sku_id: int,
70
+ **kwargs: Any,
71
+ ) -> VTEXDataResponse[DictType]:
68
72
  return self._request(
69
73
  method="GET",
70
74
  environment=self.ENVIRONMENT,
71
75
  endpoint=f"/api/catalog_system/pvt/sku/stockkeepingunitbyid/{sku_id}",
72
- config=self._config.with_overrides(**kwargs),
73
- response_class=VTEXResponse,
76
+ config=self.client.config.with_overrides(**kwargs),
77
+ response_class=VTEXDataResponse[DictType],
74
78
  )
75
79
 
76
80
  def list_categories(
@@ -78,7 +82,7 @@ class CatalogAPI(BaseAPI):
78
82
  page: int = LIST_SKU_IDS_START_PAGE,
79
83
  page_size: int = LIST_SKU_IDS_MAX_PAGE_SIZE,
80
84
  **kwargs: Any,
81
- ) -> VTEXPaginatedListResponse:
85
+ ) -> VTEXPaginatedItemsResponse[DictType, DictType]:
82
86
  return self._request(
83
87
  method="GET",
84
88
  environment=self.ENVIRONMENT,
@@ -90,28 +94,32 @@ class CatalogAPI(BaseAPI):
90
94
  MIN_PAGE_SIZE,
91
95
  ),
92
96
  },
93
- config=self._config.with_overrides(**kwargs),
94
- response_class=VTEXPaginatedListResponse,
97
+ config=self.client.config.with_overrides(**kwargs),
98
+ response_class=VTEXPaginatedItemsResponse[DictType, DictType],
95
99
  )
96
100
 
97
101
  def get_category_tree(
98
102
  self,
99
103
  levels: int = GET_CATEGORY_TREE_MAX_LEVELS,
100
104
  **kwargs: Any,
101
- ) -> VTEXResponse:
105
+ ) -> VTEXDataResponse[DictType]:
102
106
  return self._request(
103
107
  method="GET",
104
108
  environment=self.ENVIRONMENT,
105
109
  endpoint=f"/api/catalog_system/pub/category/tree/{levels}",
106
- config=self._config.with_overrides(**kwargs),
107
- response_class=VTEXResponse,
110
+ config=self.client.config.with_overrides(**kwargs),
111
+ response_class=VTEXDataResponse[DictType],
108
112
  )
109
113
 
110
- def get_category(self, category_id: str, **kwargs: Any) -> VTEXResponse:
114
+ def get_category(
115
+ self,
116
+ category_id: str,
117
+ **kwargs: Any,
118
+ ) -> VTEXDataResponse[DictType]:
111
119
  return self._request(
112
120
  method="GET",
113
121
  environment=self.ENVIRONMENT,
114
122
  endpoint=f"/api/catalog/pvt/category/{category_id}",
115
- config=self._config.with_overrides(**kwargs),
116
- response_class=VTEXResponse,
123
+ config=self.client.config.with_overrides(**kwargs),
124
+ response_class=VTEXDataResponse[DictType],
117
125
  )
@@ -1,7 +1,8 @@
1
1
  from typing import Any, List, Union
2
2
 
3
- from .._dto import VTEXCartItem, VTEXResponse
3
+ from .._dto import VTEXCartItem, VTEXDataResponse
4
4
  from .._sentinels import UNDEFINED, UndefinedSentinel
5
+ from .._types import DictType
5
6
  from .._utils import exclude_undefined_values
6
7
  from .base import BaseAPI
7
8
 
@@ -14,7 +15,7 @@ class CheckoutAPI(BaseAPI):
14
15
 
15
16
  ENVIRONMENT = "vtexcommercestable"
16
17
 
17
- def cart_simulation(
18
+ def run_cart_simulation(
18
19
  self,
19
20
  cart: List[VTEXCartItem],
20
21
  country: Union[str, UndefinedSentinel] = UNDEFINED,
@@ -24,7 +25,7 @@ class CheckoutAPI(BaseAPI):
24
25
  sales_channel: Union[int, UndefinedSentinel] = UNDEFINED,
25
26
  individual_shipping_estimates: Union[bool, UndefinedSentinel] = UNDEFINED,
26
27
  **kwargs: Any,
27
- ) -> VTEXResponse:
28
+ ) -> VTEXDataResponse[DictType]:
28
29
  return self._request(
29
30
  method="POST",
30
31
  environment=self.ENVIRONMENT,
@@ -40,6 +41,6 @@ class CheckoutAPI(BaseAPI):
40
41
  "postalCode": postal_code,
41
42
  "geoCoordinates": geo_coordinates,
42
43
  }),
43
- config=self._config.with_overrides(**kwargs),
44
- response_class=VTEXResponse,
44
+ config=self.client.config.with_overrides(**kwargs),
45
+ response_class=VTEXDataResponse[DictType],
45
46
  )
@@ -1,4 +1,5 @@
1
- from typing import Any, Type, Union
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,35 @@ class CustomAPI(BaseAPI):
46
48
  data=data,
47
49
  content=content,
48
50
  files=files,
49
- config=self._config.with_overrides(**kwargs),
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_account_site_names(self) -> datetime:
64
+ return to_datetime(
65
+ self.client.license_manager.get_account().data["creation_date"],
66
+ )
67
+
68
+ def get_main_seller(self) -> str:
69
+ return "1"
70
+
71
+ def get_market_place_sellers(self) -> List[str]:
72
+ return [
73
+ seller["seller_id"]
74
+ for seller in self.client.catalog.list_sellers(seller_type=1).items
75
+ if seller["seller_id"] != "1"
76
+ ]
77
+
78
+ def get_franchise_sellers(self) -> List[str]:
79
+ return [
80
+ seller["seller_id"]
81
+ for seller in self.client.catalog.list_sellers(seller_type=2).items
82
+ ]
@@ -1,7 +1,8 @@
1
1
  from typing import Any
2
2
 
3
- from .._dto import VTEXResponse
3
+ from .._dto import VTEXDataResponse
4
4
  from .base import BaseAPI
5
+ from .types.license_manager import GetAccountData
5
6
 
6
7
 
7
8
  class LicenseManagerAPI(BaseAPI):
@@ -12,11 +13,11 @@ class LicenseManagerAPI(BaseAPI):
12
13
 
13
14
  ENVIRONMENT = "vtexcommercestable"
14
15
 
15
- def get_account(self, **kwargs: Any) -> VTEXResponse:
16
+ def get_account(self, **kwargs: Any) -> VTEXDataResponse[GetAccountData]:
16
17
  return self._request(
17
18
  method="GET",
18
19
  environment=self.ENVIRONMENT,
19
20
  endpoint="/api/vlm/account",
20
- config=self._config.with_overrides(**kwargs),
21
- response_class=VTEXResponse,
21
+ config=self.client.config.with_overrides(**kwargs),
22
+ response_class=VTEXDataResponse[GetAccountData],
22
23
  )
@@ -9,7 +9,8 @@ from .._constants import (
9
9
  LIST_SHIPPING_POLICIES_START_PAGE,
10
10
  MIN_PAGE_SIZE,
11
11
  )
12
- from .._dto import VTEXPaginatedListResponse, VTEXResponse
12
+ from .._dto import VTEXDataResponse, VTEXPaginatedItemsResponse
13
+ from .._types import DictType
13
14
  from .base import BaseAPI
14
15
 
15
16
 
@@ -26,7 +27,7 @@ class LogisticsAPI(BaseAPI):
26
27
  page: int = LIST_SHIPPING_POLICIES_START_PAGE,
27
28
  page_size: int = LIST_SHIPPING_POLICIES_MAX_PAGE_SIZE,
28
29
  **kwargs: Any,
29
- ) -> VTEXPaginatedListResponse:
30
+ ) -> VTEXPaginatedItemsResponse[DictType, DictType]:
30
31
  return self._request(
31
32
  method="GET",
32
33
  environment=self.ENVIRONMENT,
@@ -38,21 +39,21 @@ class LogisticsAPI(BaseAPI):
38
39
  MIN_PAGE_SIZE,
39
40
  ),
40
41
  },
41
- config=self._config.with_overrides(**kwargs),
42
- response_class=VTEXPaginatedListResponse,
42
+ config=self.client.config.with_overrides(**kwargs),
43
+ response_class=VTEXPaginatedItemsResponse[DictType, DictType],
43
44
  )
44
45
 
45
46
  def get_shipping_policy(
46
47
  self,
47
48
  shipping_policy_id: str,
48
49
  **kwargs: Any,
49
- ) -> VTEXResponse:
50
+ ) -> VTEXDataResponse[DictType]:
50
51
  return self._request(
51
52
  method="GET",
52
53
  environment=self.ENVIRONMENT,
53
54
  endpoint=f"/api/logistics/pvt/shipping-policies/{shipping_policy_id}",
54
- config=self._config.with_overrides(**kwargs),
55
- response_class=VTEXResponse,
55
+ config=self.client.config.with_overrides(**kwargs),
56
+ response_class=VTEXDataResponse[DictType],
56
57
  )
57
58
 
58
59
  def list_carriers(
@@ -60,7 +61,7 @@ class LogisticsAPI(BaseAPI):
60
61
  page: int = LIST_CARRIERS_START_PAGE,
61
62
  page_size: int = LIST_CARRIERS_MAX_PAGE_SIZE,
62
63
  **kwargs: Any,
63
- ) -> VTEXPaginatedListResponse:
64
+ ) -> VTEXPaginatedItemsResponse[DictType, DictType]:
64
65
  return self._request(
65
66
  method="GET",
66
67
  environment=self.ENVIRONMENT,
@@ -72,21 +73,21 @@ class LogisticsAPI(BaseAPI):
72
73
  MIN_PAGE_SIZE,
73
74
  ),
74
75
  },
75
- config=self._config.with_overrides(**kwargs),
76
- response_class=VTEXPaginatedListResponse,
76
+ config=self.client.config.with_overrides(**kwargs),
77
+ response_class=VTEXPaginatedItemsResponse[DictType, DictType],
77
78
  )
78
79
 
79
80
  def get_carrier(
80
81
  self,
81
82
  carrier_id: str,
82
83
  **kwargs: Any,
83
- ) -> VTEXResponse:
84
+ ) -> VTEXDataResponse[DictType]:
84
85
  return self._request(
85
86
  method="GET",
86
87
  environment=self.ENVIRONMENT,
87
88
  endpoint=f"/api/logistics/pvt/configuration/carriers/{carrier_id}",
88
- config=self._config.with_overrides(**kwargs),
89
- response_class=VTEXResponse,
89
+ config=self.client.config.with_overrides(**kwargs),
90
+ response_class=VTEXDataResponse[DictType],
90
91
  )
91
92
 
92
93
  def list_docks(
@@ -94,7 +95,7 @@ class LogisticsAPI(BaseAPI):
94
95
  page: int = LIST_DOCKS_START_PAGE,
95
96
  page_size: int = LIST_DOCKS_MAX_PAGE_SIZE,
96
97
  **kwargs: Any,
97
- ) -> VTEXPaginatedListResponse:
98
+ ) -> VTEXPaginatedItemsResponse[DictType, DictType]:
98
99
  return self._request(
99
100
  method="GET",
100
101
  environment=self.ENVIRONMENT,
@@ -106,24 +107,28 @@ class LogisticsAPI(BaseAPI):
106
107
  MIN_PAGE_SIZE,
107
108
  ),
108
109
  },
109
- config=self._config.with_overrides(**kwargs),
110
- response_class=VTEXPaginatedListResponse,
110
+ config=self.client.config.with_overrides(**kwargs),
111
+ response_class=VTEXPaginatedItemsResponse[DictType, DictType],
111
112
  )
112
113
 
113
- def get_dock(self, dock_id: str, **kwargs: Any) -> VTEXResponse:
114
+ def get_dock(self, dock_id: str, **kwargs: Any) -> VTEXDataResponse[DictType]:
114
115
  return self._request(
115
116
  method="GET",
116
117
  environment=self.ENVIRONMENT,
117
118
  endpoint=f"/api/logistics/pvt/configuration/docks/{dock_id}",
118
- config=self._config.with_overrides(**kwargs),
119
- response_class=VTEXResponse,
119
+ config=self.client.config.with_overrides(**kwargs),
120
+ response_class=VTEXDataResponse[DictType],
120
121
  )
121
122
 
122
- def get_sku_inventories(self, sku_id: str, **kwargs: Any) -> VTEXResponse:
123
+ def get_sku_inventories(
124
+ self,
125
+ sku_id: str,
126
+ **kwargs: Any,
127
+ ) -> VTEXDataResponse[DictType]:
123
128
  return self._request(
124
129
  method="GET",
125
130
  environment=self.ENVIRONMENT,
126
131
  endpoint=f"/api/logistics/pvt/inventory/skus/{sku_id}",
127
- config=self._config.with_overrides(**kwargs),
128
- response_class=VTEXResponse,
132
+ config=self.client.config.with_overrides(**kwargs),
133
+ response_class=VTEXDataResponse[DictType],
129
134
  )