Add bulk product cards and weekly sales - #6
Conversation
Add products.get_cards(): fetch basic product data for many products in a single request via /api/v1/products/card (the bulk endpoint the library previously lacked). Results are mapped to a new typed ProductCard model — a trimmed, meaningful subset (name, brand, amount, unit, current/original/ unit price, sale flag and validity, stock) with website display cruft dropped — and returned in the requested order. Add products.get_week_sales(): fetch the "Akce týdne" deal ids and enrich them through get_cards in one follow-up request. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KXnkpGcLfWU4p12TcZjfY
|
@claude review |
|
Claude finished @dvejsada's task in 1m 51s —— View job Code Review
Overall this is clean, well-structured code that follows the existing conventions well. A few things worth flagging before merge:
|
…duct_ids - ProductCard.from_api: default to in-stock when availabilityStatus is absent, matching the field default (in_stock=True). - Endpoints.product_cards: URL-encode category_type defensively. - get_week_sales: guard that product_ids is a non-empty list before enriching. - Add error-path tests: get_cards on HTTP error / non-list response, and get_week_sales when the sales call or the enrichment call fails. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KXnkpGcLfWU4p12TcZjfY
Summary
Adds a bulk product fetch and a "deals of the week" feature to the client (API only — no MCP changes).
Changes
products.get_cards(product_ids, category_type="normal")— fetches basic data for many products in a single request via/api/v1/products/card(the bulk endpoint the library previously lacked). Results are returned in the requested order; IDs the API omits are skipped.ProductCardmodel — a trimmed, meaningful subset of the website's product card:id,name,brand,amount,unit,price(the sale price when on sale, otherwise the regular price),original_price,unit_price,currency,on_sale,sale_valid_till,in_stock. Display-only fields (image styling, slug, badges, tooltips, ratings, favourites, country flags) are dropped.products.get_week_sales(page=0, size=30, sort="recommended")— fetches the "Akce týdne" deal IDs from/api/v1/categories/sales/components/week-sales, then enriches them throughget_cardsin one follow-up request.ProductCardfrom the package.Tests
Regression tests built from the real
cardpayload (one regular product, one on sale) cover: card parsing, request-order preservation, the empty-input short-circuit, week-sales enrichment, and the no-deals case. Full suite: 142 passed; ruff/black/mypy clean.Notes
0.2.0(folds in with the delivery-address fix). Happy to bump to0.3.0instead if you'd rather release the address fix on its own first.get_week_salesas an MCP tool is an easy follow-up if wanted.🤖 Generated with Claude Code
Generated by Claude Code