Resolve delivery address_id from address list for timeslots - #5
Merged
Merged
Conversation
The login response does not always include a delivery address (data.address is null for some accounts), leaving user_id present but address_id None, so get_next_slots could not build the timeslots URL and returned None. Add delivery.get_addresses() and get_active_address_id() backed by the /delivery-address/list endpoint, and have get_next_slots fall back to the resolved address (preferring isDeliveredTo) and cache it on the auth manager. Bump version to 0.2.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KXnkpGcLfWU4p12TcZjfY
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
Fixes
delivery.get_next_slots()returningNonefor accounts whose login response doesn't carry a delivery address.The Rohlik login response does not always include an address —
data.addressisnullfor some accounts — souser_idis populated butaddress_idstaysNone, andget_next_slots()can't build the timeslots URL (it logs "User ID or Address ID not available for timeslots request" and returnsNone). The Home Assistant integration has the same latent gap; it only kept working because a long-lived client cached anaddress_idfrom an earlier login.Changes
Endpoints.DELIVERY_ADDRESS_LIST→/services/frontend-service/delivery-address/list.delivery.get_addresses()— returns the account's saved delivery addresses.delivery.get_active_address_id()— resolves the address id to use, preferring the first address flaggedisDeliveredTo, falling back to the first.delivery.get_next_slots()now falls back to the resolved address when login didn't supply one, and caches it on the auth manager (newAuthManager.address_idsetter) so subsequent polls are a single request.0.1.0→0.2.0.Tests
Added regression tests (built from the real
/delivery-address/listpayload shape) coveringget_addresses,get_active_address_idpreference order, andget_next_slotsresolving + caching the address. Full suite: 138 passed, ruff/black/mypy clean.Verification note
The live login endpoint bot-blocks this CI/datacenter IP (returns
202instead of200), so end-to-end validation was done with mocked responses using the real payload. Final live confirmation (timeslots returns slots for the resolved address id) is being verified from a residential connection before release.🤖 Generated with Claude Code
Generated by Claude Code