Skip to content

Commit

Permalink
PR for aplus param changes (#198)
Browse files Browse the repository at this point in the history
* video param changes for product object query

* aplus content product object param

* updated merge

* add aplus test to product query

---------

Co-authored-by: Alex Kaszynski <akascap@gmail.com>
  • Loading branch information
The-Winnster and akaszynski authored Feb 7, 2025
1 parent f61f7f0 commit 652a70d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/keepa/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ def query(
only_live_offers: Optional[bool] = None,
raw: bool = False,
videos: bool = False,
aplus: bool = False,
) -> List[Dict[str, Any]]:
"""Perform a product query of a list, array, or single ASIN.
Expand Down Expand Up @@ -633,7 +634,7 @@ def query(
When ``True``, return the raw request response. This is only
available in the non-async class.
videos : bool, optional
videos : bool, default: False
Token Cost: No extra token cost
If ``True``, the videos metadata will be provided when
Expand All @@ -642,6 +643,15 @@ def query(
available. If you need up-to-date data, you have to use the offers
parameter.
aplus : bool, default: False
Token Cost: No extra token cost
If set to ``True`` the A+ content will be provided when
available. Using this parameter does not trigger an update to the
A+ content; it only gives access to our existing data if
available. If you need up-to-date data, you have to use the offers
parameter.
Returns
-------
list
Expand Down Expand Up @@ -908,6 +918,7 @@ def query(
only_live_offers=only_live_offers,
raw=raw,
videos=videos,
aplus=aplus,
)
idx += nrequest
if raw:
Expand Down Expand Up @@ -951,10 +962,6 @@ def _product_query(self, items, product_code_is_asin=True, **kwargs):
history of a product. Set to False to reduce request time
if data is not required.
as_asin : bool, optional
Queries keepa using asin codes. Otherwise, queries using
the code key.
Returns
-------
products : list
Expand Down Expand Up @@ -993,6 +1000,7 @@ def _product_query(self, items, product_code_is_asin=True, **kwargs):
kwargs["rating"] = int(kwargs["rating"])
kwargs["buybox"] = int(kwargs["buybox"])
kwargs["videos"] = int(kwargs["videos"])
kwargs["aplus"] = int(kwargs["aplus"])

if kwargs["update"] is None:
del kwargs["update"]
Expand Down Expand Up @@ -1778,6 +1786,7 @@ async def query(
only_live_offers: Optional[bool] = None,
raw: bool = False,
videos: bool = False,
aplus: bool = False,
):
"""Documented in Keepa.query."""
if raw:
Expand Down
9 changes: 8 additions & 1 deletion tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def test_seller_query_long_list(api):
api.seller_query(seller_id)


def test_video_query(api) -> None:
def test_video_query(api: keepa.Keepa) -> None:
"""Test if the videos query parameter works."""
response = api.query("B00UFMKSDW", history=False, videos=False)
product = response[0]
Expand All @@ -434,3 +434,10 @@ def test_video_query(api) -> None:
response = api.query("B00UFMKSDW", history=False, videos=True)
product = response[0]
assert "videos" in product


def test_aplus(api: keepa.Keepa) -> None:
product_nominal = api.query("B0DDDD8WD6", history=False, aplus=False)[0]
assert "aPlus" not in product_nominal
product_aplus = api.query("B0DDDD8WD6", history=False, aplus=True)[0]
assert "aPlus" in product_aplus

0 comments on commit 652a70d

Please sign in to comment.