vtexpy 0.0.0b38__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/_vtex.py +7 -0
- {vtexpy-0.0.0b38.dist-info → vtexpy-0.0.0b39.dist-info}/METADATA +1 -1
- {vtexpy-0.0.0b38.dist-info → vtexpy-0.0.0b39.dist-info}/RECORD +10 -9
- {vtexpy-0.0.0b38.dist-info → vtexpy-0.0.0b39.dist-info}/WHEEL +0 -0
- {vtexpy-0.0.0b38.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/_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,19 +1,20 @@
|
|
|
1
1
|
vtex/__init__.py,sha256=SLnqpZa19ISSQ9LDaCVLDAj-OxFlgVkQyEknydu20VU,636
|
|
2
2
|
vtex/_config.py,sha256=EhvVHgby0PY4rdIlKbWsH8y3fugDoxaQCCOLahzQY1w,12301
|
|
3
|
-
vtex/_constants.py,sha256=
|
|
4
|
-
vtex/_dto.py,sha256=
|
|
3
|
+
vtex/_constants.py,sha256=xf6xlpu9tvtRHGQXPp38WIvw5xQA3DDY8VVuD7Ogpd8,2158
|
|
4
|
+
vtex/_dto.py,sha256=78PamXGpmaSoGzh8yVDGpZPk_NBsPglzFilP8dDDKas,6866
|
|
5
5
|
vtex/_exceptions.py,sha256=dNRhdk6k4capnsUSHPOKsvACwLfG8cwTNXltao3t344,2152
|
|
6
6
|
vtex/_logging.py,sha256=zahPJIk10YvNs6qoNqhUy7OoDG7dr634CPwiGjT0aEk,2246
|
|
7
7
|
vtex/_sentinels.py,sha256=HLkYBJVHTx9GoyACPO1SuINaGlU2YiqOPuFXUa7iG8A,1120
|
|
8
8
|
vtex/_types.py,sha256=xrqHzmrc0IhE5fc1aGf0StCm3BQbVFyk3LG4Hd7Wd2Q,631
|
|
9
9
|
vtex/_utils.py,sha256=GHNxlqBs73KXHN8Aejh7dT9dhFLhBk13EN-9nIEaimk,3413
|
|
10
|
-
vtex/_vtex.py,sha256=
|
|
10
|
+
vtex/_vtex.py,sha256=EzoeKbZl7A3L7h27x8-RwhYh3-TD0snLtfaBR3OSis4,2551
|
|
11
11
|
vtex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
vtex/_api/__init__.py,sha256=
|
|
12
|
+
vtex/_api/__init__.py,sha256=MPOCizaeIYfdKr5xv23QuLc3ouyJiYOohUYkwJ19uPk,438
|
|
13
13
|
vtex/_api/base.py,sha256=Pjww58gnM31C7Oo0AC_TNOcqLM8mSmfk2kQfnVyaQnQ,7079
|
|
14
|
-
vtex/_api/catalog.py,sha256=
|
|
14
|
+
vtex/_api/catalog.py,sha256=vfUHWd6lbRyivszzgIIexJB-bt2mpBLZLfQZAJAcngg,4667
|
|
15
15
|
vtex/_api/checkout.py,sha256=ViFJq2GZRAA6yyjaFC3rz0oMYKxzBIsi8tzGKCWRxQ0,1693
|
|
16
16
|
vtex/_api/custom.py,sha256=3yIwTj1Ikf30oq0GzdNz0P9APYxjBeoRvdlbh0rT9gs,2930
|
|
17
|
+
vtex/_api/intelligent_search.py,sha256=28BbxveOyd-7xaQ_ynxBSNX1H5t9fsOvxnBPllE-OB8,2596
|
|
17
18
|
vtex/_api/license_manager.py,sha256=GAdRpizeGUFem-up-SYNzehs5uBY0elTElJ9bEQUlFo,2805
|
|
18
19
|
vtex/_api/logistics.py,sha256=bd55wipbnql3OFnDCBsjP0-jp7OY6FP10Yz5acOsG2o,5052
|
|
19
20
|
vtex/_api/master_data.py,sha256=HGoWr908iQYb0kzq_KNvKyWKtaNQ9vTv7CXxvKey0AM,2046
|
|
@@ -25,7 +26,7 @@ vtex/_api/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
25
26
|
vtex/_api/types/catalog.py,sha256=O_qLoiGMyBxRdmxPclbbPobUxJSzViqzHiKf8tgfm_I,394
|
|
26
27
|
vtex/_api/types/generic.py,sha256=m1lFTPeyBNi-K0shvK4uxE5SUyvhTTX_5Ls2VockkdI,344
|
|
27
28
|
vtex/_api/types/license_manager.py,sha256=KYISnKdQ548g6x5cNieoaN6gh9C1LQVFv4sH-II1maI,1015
|
|
28
|
-
vtexpy-0.0.
|
|
29
|
-
vtexpy-0.0.
|
|
30
|
-
vtexpy-0.0.
|
|
31
|
-
vtexpy-0.0.
|
|
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
|
|
File without changes
|