Skip to content

Conversation

@HelgeSverre
Copy link

Summary

This PR adds support for all missing API parameters in the product_search method to achieve complete parity with the Kassal.app /products endpoint.

New Filter Options Added

  • store - Filter products by store codes (e.g., "SPAR_NO", "MENY_NO")
  • has_labels - Filter products by labels (e.g., ["euroleaf", "frysevare"])
  • category - Filter products by category name (e.g., "dairy")
  • category_id - Filter products by category ID

Changes Made

Client Library (kassalappy/client.py)

  • Added 4 missing parameters to product_search() method
  • Updated parameter dictionary and docstrings
  • Maintains full backward compatibility

CLI Enhancement (kassalappy/cli.py)

  • Added --store option with PhysicalStoreGroup validation
  • Added --category option for category filtering
  • Both options integrate seamlessly with existing CLI

Test Coverage (tests/)

  • Created comprehensive product search fixture
  • Added 5 new test cases covering all filtering scenarios
  • Tests validate basic search, store filtering, category filtering, label filtering, and combined filters

Documentation

  • Added CLAUDE.md with development guidance
  • Updated all docstrings with parameter descriptions

Testing

Unit Tests: All 6 tests pass (including original + 5 new product search tests)

Real API Testing: Verified with actual Kassal.app API:

  • Store filtering works correctly (store="SPAR_NO" returns only SPAR products)
  • Category filtering functions as expected
  • Basic search returns products from multiple stores

CLI Testing: Command-line interface verified working:

kassalappy product "milk" --store SPAR_NO --count 2

Usage Examples

Programmatic Usage

# Filter by store
products = await client.product_search(search="milk", store="SPAR_NO")

# Filter by category  
products = await client.product_search(search="bread", category="bakery")

# Filter by labels
products = await client.product_search(search="milk", has_labels=["euroleaf"])

# Combined filters
products = await client.product_search(
    search="milk", 
    store="MENY_NO", 
    category="dairy",
    has_labels=["euroleaf"]
)

CLI Usage

# Filter by store
kassalappy product "milk" --store SPAR_NO

# Filter by category
kassalappy product "bread" --category bakery

# Combined filters
kassalappy product "milk" --store MENY_NO --category dairy

This implementation provides complete access to the Kassal.app API's filtering capabilities while maintaining backward compatibility.

🤖 Generated with Claude Code

Add support for all missing API parameters in product_search method:
- store: Filter products by store codes (e.g., SPAR_NO, MENY_NO)
- has_labels: Filter products by labels (e.g., euroleaf, frysevare)
- category: Filter products by category name (e.g., dairy)
- category_id: Filter products by category ID

This provides complete API parity with the Kassal.app /products endpoint.

Changes:
- Updated product_search method in client.py with new parameters
- Added CLI support for --store and --category options
- Created comprehensive test suite with fixtures
- Added CLAUDE.md documentation for future development

Tested with real API to verify functionality works correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@HelgeSverre
Copy link
Author

TL;DR: claude la til noen nye filtervalg på produktsøk-funksjonen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant