Migrate to Krónan Public API#3
Merged
Merged
Conversation
This PR migrates the CLI from the legacy backend API to the new official Krónan Public API (https://api.kronan.is/api/v1/). Key changes: - Replace Cognito JWT auth with AccessToken authentication - Update all API endpoints to match Public API specification - Add support for new features: product lists, shopping notes, purchase stats - Update CLI commands: 'token' replaces 'login', improved cart handling - Fix response format handling (some endpoints return objects vs arrays) - Update all documentation (README, CLAUDE.md) - Update and add tests for new API structure Breaking changes: - 'kronan login <phone>' removed - use 'kronan token <access-token>' instead - Auth tokens stored in ~/.kronan/token instead of ~/.kronan/tokens.json - Cart commands simplified (replace/update/remove -> add/clear) See https://api.kronan.is/api/v1/schema/swagger-ui/ for API docs.
f3d4f67 to
8c9d710
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the CLI from the legacy backend API to the new official Krónan Public API (https://api.kronan.is/api/v1/).
The Krónan Public API was recently announced as a beta release, providing a cleaner, more stable interface for interacting with Krónan's e-commerce platform.
Key Changes
🔐 Authentication
kronan token <access-token>(replaceskronan login <phone>)~/.kronan/token(simplified from JSON format)🌐 API Updates
https://api.kronan.is/api/v1(washttps://backend.kronan.is/api)Authorization: AccessToken <token>(wasCognitoJWT)🛠️ CLI Commands (Comprehensive)
Authentication:
kronan token <token>- Save access tokenkronan logout- Clear stored tokenkronan status- Check authentication statusProducts:
kronan search <query>- Search for productskronan product <sku>- Get product detailskronan categories- List all categorieskronan category <slug>- Browse products by categoryOrders:
kronan orders- View order historykronan order <token>- View specific order detailskronan order delete-lines <token> <lineIds...>- Delete order lineskronan order lower-quantity <token> <lineIds...> --quantity N- Lower quantitykronan order toggle-substitution <token> <lineIds...>- Toggle substitutionCart:
kronan cart- View cart contentskronan cart add <sku> [qty]- Add item to cartkronan cart clear- Clear cartProduct Lists:
kronan lists- List all product listskronan lists create <name> [--description "..."]- Create new listkronan lists view <token>- View list detailskronan lists delete <token> [--force]- Delete a listkronan lists add <list-token> <sku> [qty]- Add item to listkronan lists remove <list-token> <sku>- Remove item from listkronan lists clear <token> [--force]- Clear all items from listShopping Notes (Skundalisti):
kronan notes- View shopping notekronan notes add [--text "..."] [--sku SKU] [--quantity N]- Add itemkronan notes update <line-token> [--text "..."] [--quantity N]- Update itemkronan notes remove <line-token>- Remove item from notekronan notes toggle <line-token>- Toggle item completionkronan notes clear [--force]- Clear all items from notekronan notes archived- View completed itemsPurchase Statistics:
kronan stats [--limit N] [--offset N] [--include-ignored]- View purchase historykronan stats ignore <id>- Hide product from statskronan stats unignore <id>- Unhide product from statsIdentity:
kronan me- Show current identity🧪 Testing
📚 Documentation
API Reference
Testing Done
✅ Token authentication works
✅ Product search (with pagination)
✅ Product details
✅ Categories and category browsing
✅ Order history and details
✅ Order modifications (delete lines, lower quantity, toggle substitution)
✅ Cart view, add, clear
✅ Product lists (full CRUD)
✅ Shopping notes (full management)
✅ Purchase statistics
✅ All tests passing
Breaking Changes
kronan token <your-new-token>~/.kronan/tokens.jsoncan be removedRelated
Krónan announcement: https://www.facebook.com/kronan/posts/...