Skip to content

Commit 705e182

Browse files
committed
feat: catalog next page allows for extra kwargs
1 parent dd157da commit 705e182

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ data = walmart_io.catalog_product(category='3944', maxId='8342714')
7272

7373
A catalog response contains category, format, nextPage, totalPages, and a list of items
7474

75+
The returned API data is paginated. To get the next page, pass in `data.nextPage` as a kwarg.
76+
All other kwargs will be stripped out. They will be embed in the nextPage response.
77+
78+
```py
79+
data = walmart_io.catalog_product(category="3944", maxId="8342714")
80+
next_data = walmart_io.catalog_product(nextPage=data.nextPage)
81+
# or
82+
next_data = walmart_io.catalog_product(category="3944", maxId="8342714", nextPage=data.nextPage)
83+
```
84+
7585
### [Post Browsed Products](https://walmart.io/docs/affiliate/post-browsed-products)
7686

7787
The post browsed products API allows you to recommend products to someone based on their product viewing history.

wiopy/AsyncWIO.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ async def catalog_product(self, **kwargs: str | int | bool) -> WalmartCatalog:
168168
https://www.walmart.io/docs/affiliate/catalog-product
169169
170170
"""
171-
if next_page := kwargs.get("nextPage"):
171+
if next_page := kwargs.pop("nextPage", ""):
172172
assert isinstance(next_page, str), ValueError(
173173
"Expected type string for kwarg 'nextPage'"
174174
)
175175
url = "https://developer.api.walmart.com" + next_page
176-
return WalmartCatalog(await self._send_request(url, **kwargs))
176+
return WalmartCatalog(await self._send_request(url))
177177

178178
url = self.ENDPOINT + "/affil/product/v2/paginated/items"
179179
return WalmartCatalog(await self._send_request(url, **kwargs))

wiopy/WalmartIO.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ def catalog_product(self, **kwargs: str | int | bool) -> WalmartCatalog:
168168
https://www.walmart.io/docs/affiliate/catalog-product
169169
170170
"""
171-
if next_page := kwargs.get("nextPage"):
171+
if next_page := kwargs.pop("nextPage", ""):
172172
assert isinstance(next_page, str), ValueError(
173173
"Expected type string for kwarg 'nextPage'"
174174
)
175175
url = "https://developer.api.walmart.com" + next_page
176-
return WalmartCatalog(self._send_request(url, **kwargs))
176+
return WalmartCatalog(self._send_request(url))
177177

178178
url = self.ENDPOINT + "/affil/product/v2/paginated/items"
179179
return WalmartCatalog(self._send_request(url, **kwargs))

0 commit comments

Comments
 (0)