vtexpy 0.0.0b37__py3-none-any.whl → 0.0.0b39__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/__init__.py +1 -0
- vtex/_api/catalog.py +2 -2
- vtex/_api/intelligent_search.py +68 -0
- vtex/_constants.py +4 -0
- vtex/_dto.py +7 -0
- vtex/_utils.py +8 -2
- vtex/_vtex.py +7 -0
- {vtexpy-0.0.0b37.dist-info → vtexpy-0.0.0b39.dist-info}/METADATA +17 -21
- {vtexpy-0.0.0b37.dist-info → vtexpy-0.0.0b39.dist-info}/RECORD +17 -16
- {vtexpy-0.0.0b37.dist-info → vtexpy-0.0.0b39.dist-info}/WHEEL +1 -1
- {vtexpy-0.0.0b37.dist-info → vtexpy-0.0.0b39.dist-info/licenses}/LICENSE +0 -0
vtex/_api/__init__.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .catalog import CatalogAPI
|
|
2
2
|
from .checkout import CheckoutAPI
|
|
3
3
|
from .custom import CustomAPI
|
|
4
|
+
from .intelligent_search import IntelligentSearchAPI
|
|
4
5
|
from .license_manager import LicenseManagerAPI
|
|
5
6
|
from .logistics import LogisticsAPI
|
|
6
7
|
from .master_data import MasterDataAPI
|
vtex/_api/catalog.py
CHANGED
|
@@ -91,8 +91,8 @@ class CatalogAPI(BaseAPI):
|
|
|
91
91
|
|
|
92
92
|
def list_categories(
|
|
93
93
|
self,
|
|
94
|
-
page: int =
|
|
95
|
-
page_size: int =
|
|
94
|
+
page: int = LIST_CATEGORIES_START_PAGE,
|
|
95
|
+
page_size: int = LIST_CATEGORIES_MAX_PAGE_SIZE,
|
|
96
96
|
**kwargs: Any,
|
|
97
97
|
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
98
98
|
return self._request(
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from typing import Any, Literal, Union
|
|
2
|
+
|
|
3
|
+
from .._constants import (
|
|
4
|
+
INTELLIGENT_PRODUCT_SEARCH_MAX_PAGE_SIZE,
|
|
5
|
+
INTELLIGENT_PRODUCT_SEARCH_START_PAGE,
|
|
6
|
+
MIN_PAGE_SIZE,
|
|
7
|
+
)
|
|
8
|
+
from .._dto import VTEXPaginatedItemsResponse
|
|
9
|
+
from .._sentinels import UNDEFINED, UndefinedSentinel
|
|
10
|
+
from .._types import OrderingDirectionType
|
|
11
|
+
from .._utils import omitting_undefined
|
|
12
|
+
from .base import BaseAPI
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class IntelligentSearchAPI(BaseAPI):
|
|
16
|
+
"""
|
|
17
|
+
Client for the Intelligent Search API.
|
|
18
|
+
https://developers.vtex.com/docs/api-reference/intelligent-search-api
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
ENVIRONMENT = "vtexcommercestable"
|
|
22
|
+
|
|
23
|
+
def search_products(
|
|
24
|
+
self,
|
|
25
|
+
product_ids: Union[list[str], UndefinedSentinel] = UNDEFINED,
|
|
26
|
+
sku_ids: Union[list[str], UndefinedSentinel] = UNDEFINED,
|
|
27
|
+
simulation_behavior: str = "skip",
|
|
28
|
+
show_sponsored: bool = True,
|
|
29
|
+
fuzzy: bool = True,
|
|
30
|
+
operator: Literal["and", "or"] = "and",
|
|
31
|
+
order_by_field: str = "release",
|
|
32
|
+
order_by_direction: OrderingDirectionType = "desc",
|
|
33
|
+
page: int = INTELLIGENT_PRODUCT_SEARCH_START_PAGE,
|
|
34
|
+
page_size: int = INTELLIGENT_PRODUCT_SEARCH_MAX_PAGE_SIZE,
|
|
35
|
+
**kwargs: Any,
|
|
36
|
+
) -> VTEXPaginatedItemsResponse[Any, Any]:
|
|
37
|
+
"""
|
|
38
|
+
Search for products in the catalog.
|
|
39
|
+
"""
|
|
40
|
+
if product_ids and sku_ids:
|
|
41
|
+
raise ValueError("You can only search by product IDs or SKU IDs, not both.")
|
|
42
|
+
|
|
43
|
+
q: Union[str, UndefinedSentinel] = UNDEFINED
|
|
44
|
+
if isinstance(product_ids, list) and product_ids:
|
|
45
|
+
q = f"product.id:{';'.join([str(id) for id in product_ids])}"
|
|
46
|
+
elif isinstance(sku_ids, list) and sku_ids:
|
|
47
|
+
q = f"sku.id:{';'.join([str(id) for id in sku_ids])}"
|
|
48
|
+
|
|
49
|
+
return self._request(
|
|
50
|
+
method="GET",
|
|
51
|
+
endpoint="/api/io/_v/api/intelligent-search/product_search/",
|
|
52
|
+
environment=self.ENVIRONMENT,
|
|
53
|
+
params=omitting_undefined({
|
|
54
|
+
"q": q,
|
|
55
|
+
"simulationBehavior": simulation_behavior,
|
|
56
|
+
"showSponsored": show_sponsored,
|
|
57
|
+
"fuzzy": fuzzy,
|
|
58
|
+
"operator": operator,
|
|
59
|
+
"sort": f"{order_by_field}:{order_by_direction}",
|
|
60
|
+
"page": max(page, INTELLIGENT_PRODUCT_SEARCH_START_PAGE),
|
|
61
|
+
"count": max(
|
|
62
|
+
min(page_size, INTELLIGENT_PRODUCT_SEARCH_MAX_PAGE_SIZE),
|
|
63
|
+
MIN_PAGE_SIZE,
|
|
64
|
+
),
|
|
65
|
+
}),
|
|
66
|
+
config=self.client.config.with_overrides(**kwargs),
|
|
67
|
+
response_class=VTEXPaginatedItemsResponse[Any, Any],
|
|
68
|
+
)
|
vtex/_constants.py
CHANGED
|
@@ -56,6 +56,10 @@ DEFAULT_LOG_5XX = WARNING
|
|
|
56
56
|
# Generics
|
|
57
57
|
MIN_PAGE_SIZE = 1
|
|
58
58
|
|
|
59
|
+
# Intelligent Search
|
|
60
|
+
INTELLIGENT_PRODUCT_SEARCH_START_PAGE = 1
|
|
61
|
+
INTELLIGENT_PRODUCT_SEARCH_MAX_PAGE_SIZE = 100
|
|
62
|
+
|
|
59
63
|
# Catalog
|
|
60
64
|
LIST_SKU_IDS_START_PAGE = 1
|
|
61
65
|
LIST_SKU_IDS_MAX_PAGE_SIZE = 1_000
|
vtex/_dto.py
CHANGED
|
@@ -91,6 +91,8 @@ class VTEXItemsResponse(VTEXDataResponse[DataType], Generic[DataType, ItemType])
|
|
|
91
91
|
items = data["items"]
|
|
92
92
|
elif isinstance(data, dict) and isinstance(data.get("data"), list):
|
|
93
93
|
items = data["data"]
|
|
94
|
+
elif isinstance(data, dict) and isinstance(data.get("products"), list):
|
|
95
|
+
items = data["products"]
|
|
94
96
|
else:
|
|
95
97
|
raise ValueError(f"Not a valid items response: {data}")
|
|
96
98
|
|
|
@@ -135,6 +137,11 @@ class VTEXPagination(BaseModel):
|
|
|
135
137
|
page_size = data["size"]
|
|
136
138
|
pages = data["total_page"]
|
|
137
139
|
page = data["page"]
|
|
140
|
+
elif isinstance(data, dict) and data.get("pagination"):
|
|
141
|
+
total = data["records_filtered"]
|
|
142
|
+
page_size = data["pagination"]["per_page"]
|
|
143
|
+
pages = data["pagination"]["count"]
|
|
144
|
+
page = data["pagination"]["current"]["index"]
|
|
138
145
|
elif "rest-content-range" in response_headers:
|
|
139
146
|
request_pagination = request_headers["rest-range"].split("=")[-1].split("-")
|
|
140
147
|
response_pagination = response_headers["rest-content-range"].split(" ")[-1]
|
vtex/_utils.py
CHANGED
|
@@ -5,7 +5,6 @@ from uuid import UUID
|
|
|
5
5
|
|
|
6
6
|
from dateutil.parser import parse as parse_datetime
|
|
7
7
|
from dateutil.tz import tzoffset
|
|
8
|
-
from distutils.util import strtobool
|
|
9
8
|
|
|
10
9
|
from ._constants import APP_KEY_HEADER, APP_TOKEN_HEADER
|
|
11
10
|
from ._logging import UTILS_LOGGER
|
|
@@ -16,7 +15,14 @@ TO_SNAKE_CASE_STEP_2_PATTERN = compile(r"([a-z0-9])([A-Z])")
|
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
def str_to_bool(value: str) -> bool:
|
|
19
|
-
|
|
18
|
+
if isinstance(value, str):
|
|
19
|
+
if value.lower() in {"true", "yes", "on", "y", "1"}:
|
|
20
|
+
return True
|
|
21
|
+
|
|
22
|
+
if value.lower() in {"false", "no", "off", "n", "0"}:
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
raise ValueError(f"Invalid boolean repreentation: {value}")
|
|
20
26
|
|
|
21
27
|
|
|
22
28
|
def omitting_undefined(obj: Dict[Any, Any]) -> Dict[Any, Any]:
|
vtex/_vtex.py
CHANGED
|
@@ -9,6 +9,7 @@ if TYPE_CHECKING:
|
|
|
9
9
|
CatalogAPI,
|
|
10
10
|
CheckoutAPI,
|
|
11
11
|
CustomAPI,
|
|
12
|
+
IntelligentSearchAPI,
|
|
12
13
|
LicenseManagerAPI,
|
|
13
14
|
LogisticsAPI,
|
|
14
15
|
MasterDataAPI,
|
|
@@ -53,6 +54,12 @@ class VTEX:
|
|
|
53
54
|
|
|
54
55
|
return CheckoutAPI(client=self)
|
|
55
56
|
|
|
57
|
+
@cached_property
|
|
58
|
+
def intelligent_search(self) -> "IntelligentSearchAPI":
|
|
59
|
+
from ._api import IntelligentSearchAPI
|
|
60
|
+
|
|
61
|
+
return IntelligentSearchAPI(client=self)
|
|
62
|
+
|
|
56
63
|
@cached_property
|
|
57
64
|
def license_manager(self) -> "LicenseManagerAPI":
|
|
58
65
|
from ._api import LicenseManagerAPI
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: vtexpy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.0b39
|
|
4
4
|
Summary: Unofficial VTEX API's Python SDK
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Author: Luis Vieira
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
Project-URL: homepage, https://github.com/lvieirajr/vtex-python
|
|
6
|
+
Project-URL: repository, https://github.com/lvieirajr/vtex-python
|
|
7
|
+
Project-URL: documentation, https://github.com/lvieirajr/vtex-python
|
|
8
|
+
Author-email: Luis Vieira <lvieira@lvieira.com>
|
|
9
|
+
Maintainer-email: Luis Vieira <lvieira@lvieira.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,client,sdk,vtex
|
|
13
13
|
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
-
Classifier: License :: Other/Proprietary License
|
|
17
16
|
Classifier: Operating System :: OS Independent
|
|
18
17
|
Classifier: Programming Language :: Python
|
|
19
18
|
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
21
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
22
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -25,14 +23,13 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
25
23
|
Classifier: Topic :: Software Development :: Libraries
|
|
26
24
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
25
|
Classifier: Typing :: Typed
|
|
28
|
-
Requires-
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist:
|
|
34
|
-
|
|
35
|
-
Project-URL: Repository, https://github.com/lvieirajr/vtex-python
|
|
26
|
+
Requires-Python: <3.14,>=3.10
|
|
27
|
+
Requires-Dist: cachetools<6.0,>=5.0
|
|
28
|
+
Requires-Dist: httpx<1.0,>=0.17
|
|
29
|
+
Requires-Dist: pydantic<3.0,>=2.0
|
|
30
|
+
Requires-Dist: python-dateutil<3.0,>=2.9
|
|
31
|
+
Requires-Dist: tenacity<10.0,>=8.0
|
|
32
|
+
Requires-Dist: typing-extensions<5.0,>=3.10; python_version < '3.12'
|
|
36
33
|
Description-Content-Type: text/markdown
|
|
37
34
|
|
|
38
35
|
# VTEXPY
|
|
@@ -99,4 +96,3 @@ response = vtex_client.custom.request(
|
|
|
99
96
|
# Other arguments such as: query params, headers, json data, response class, etc...
|
|
100
97
|
)
|
|
101
98
|
```
|
|
102
|
-
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
vtex/__init__.py,sha256=SLnqpZa19ISSQ9LDaCVLDAj-OxFlgVkQyEknydu20VU,636
|
|
2
|
-
vtex/
|
|
2
|
+
vtex/_config.py,sha256=EhvVHgby0PY4rdIlKbWsH8y3fugDoxaQCCOLahzQY1w,12301
|
|
3
|
+
vtex/_constants.py,sha256=xf6xlpu9tvtRHGQXPp38WIvw5xQA3DDY8VVuD7Ogpd8,2158
|
|
4
|
+
vtex/_dto.py,sha256=78PamXGpmaSoGzh8yVDGpZPk_NBsPglzFilP8dDDKas,6866
|
|
5
|
+
vtex/_exceptions.py,sha256=dNRhdk6k4capnsUSHPOKsvACwLfG8cwTNXltao3t344,2152
|
|
6
|
+
vtex/_logging.py,sha256=zahPJIk10YvNs6qoNqhUy7OoDG7dr634CPwiGjT0aEk,2246
|
|
7
|
+
vtex/_sentinels.py,sha256=HLkYBJVHTx9GoyACPO1SuINaGlU2YiqOPuFXUa7iG8A,1120
|
|
8
|
+
vtex/_types.py,sha256=xrqHzmrc0IhE5fc1aGf0StCm3BQbVFyk3LG4Hd7Wd2Q,631
|
|
9
|
+
vtex/_utils.py,sha256=GHNxlqBs73KXHN8Aejh7dT9dhFLhBk13EN-9nIEaimk,3413
|
|
10
|
+
vtex/_vtex.py,sha256=EzoeKbZl7A3L7h27x8-RwhYh3-TD0snLtfaBR3OSis4,2551
|
|
11
|
+
vtex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
vtex/_api/__init__.py,sha256=MPOCizaeIYfdKr5xv23QuLc3ouyJiYOohUYkwJ19uPk,438
|
|
3
13
|
vtex/_api/base.py,sha256=Pjww58gnM31C7Oo0AC_TNOcqLM8mSmfk2kQfnVyaQnQ,7079
|
|
4
|
-
vtex/_api/catalog.py,sha256=
|
|
14
|
+
vtex/_api/catalog.py,sha256=vfUHWd6lbRyivszzgIIexJB-bt2mpBLZLfQZAJAcngg,4667
|
|
5
15
|
vtex/_api/checkout.py,sha256=ViFJq2GZRAA6yyjaFC3rz0oMYKxzBIsi8tzGKCWRxQ0,1693
|
|
6
16
|
vtex/_api/custom.py,sha256=3yIwTj1Ikf30oq0GzdNz0P9APYxjBeoRvdlbh0rT9gs,2930
|
|
17
|
+
vtex/_api/intelligent_search.py,sha256=28BbxveOyd-7xaQ_ynxBSNX1H5t9fsOvxnBPllE-OB8,2596
|
|
7
18
|
vtex/_api/license_manager.py,sha256=GAdRpizeGUFem-up-SYNzehs5uBY0elTElJ9bEQUlFo,2805
|
|
8
19
|
vtex/_api/logistics.py,sha256=bd55wipbnql3OFnDCBsjP0-jp7OY6FP10Yz5acOsG2o,5052
|
|
9
20
|
vtex/_api/master_data.py,sha256=HGoWr908iQYb0kzq_KNvKyWKtaNQ9vTv7CXxvKey0AM,2046
|
|
@@ -15,17 +26,7 @@ vtex/_api/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
15
26
|
vtex/_api/types/catalog.py,sha256=O_qLoiGMyBxRdmxPclbbPobUxJSzViqzHiKf8tgfm_I,394
|
|
16
27
|
vtex/_api/types/generic.py,sha256=m1lFTPeyBNi-K0shvK4uxE5SUyvhTTX_5Ls2VockkdI,344
|
|
17
28
|
vtex/_api/types/license_manager.py,sha256=KYISnKdQ548g6x5cNieoaN6gh9C1LQVFv4sH-II1maI,1015
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
vtex/_logging.py,sha256=zahPJIk10YvNs6qoNqhUy7OoDG7dr634CPwiGjT0aEk,2246
|
|
23
|
-
vtex/_sentinels.py,sha256=HLkYBJVHTx9GoyACPO1SuINaGlU2YiqOPuFXUa7iG8A,1120
|
|
24
|
-
vtex/_types.py,sha256=xrqHzmrc0IhE5fc1aGf0StCm3BQbVFyk3LG4Hd7Wd2Q,631
|
|
25
|
-
vtex/_utils.py,sha256=ngC2rRdhBO5cjAAByS0_2LMeXKsI6rnfiHGP96U0m88,3215
|
|
26
|
-
vtex/_vtex.py,sha256=IBPVQ__xiQGJEoht4oCnd-pAYKNJDrKoU06yieQL84o,2342
|
|
27
|
-
vtex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
-
vtexpy-0.0.0b37.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
29
|
-
vtexpy-0.0.0b37.dist-info/METADATA,sha256=8paK-gNGnAoLzzrjKziD7wEH7jyw3MrwpHrwLGXVNcc,3493
|
|
30
|
-
vtexpy-0.0.0b37.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
31
|
-
vtexpy-0.0.0b37.dist-info/RECORD,,
|
|
29
|
+
vtexpy-0.0.0b39.dist-info/METADATA,sha256=iyWH9ndOiB63tQmiBNdRKhWmLn8FGdSXvMynocuP0NM,3408
|
|
30
|
+
vtexpy-0.0.0b39.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
31
|
+
vtexpy-0.0.0b39.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
32
|
+
vtexpy-0.0.0b39.dist-info/RECORD,,
|
|
File without changes
|