Skip to content

Add search and locations, fix session refresh, publish with images - #3

Merged
tomLadder merged 3 commits into
mainfrom
feat/search-locations-session-fix
Oct 30, 2026
Merged

tomLadder merged 3 commits into
mainfrom
feat/search-locations-session-fix

Conversation

@tomLadder

Copy link
Copy Markdown
Owner

Summary

New commands

  • search [keyword...]: search marketplace listings without logging in. Filters for price, state, private/dealer, PayLivery, recency and sort, plus --facets to list every available filter (category, condition, delivery, ...) with its --filter value. Supports --json.
  • locations <postcode>: look up location ids for a postcode.
  • activate <id>: put a draft live.

Publishing

  • publish resolves locationId from postCode and location, so templates no longer need it. The location ids in the docs were wrong (e.g. 900 for Wien), so I removed them.
  • publish uploads the template's images before the listing goes live. If an upload fails, the listing stays a draft and the error contains its id.
  • --draft was accepted but ignored. It now keeps the listing as a draft.

Session

  • On refresh, the CLI kept only the new access token and dropped the rotated refresh token, so sessions died after the refresh token's idle timeout. It now stores both.
  • An expired session returns a clear "run willhaben login" error instead of a bare 401.
  • whoami shows whether the session is active.

Fixes

  • list and get mapped the ad status differently, and neither knew sold (120). Sold ads showed as active or inactive. Both now use one mapping and know draft, pending, rejected and sold.
  • get and categories work without login.
  • Request headers are defined in one place (src/api/headers.ts) and use the Android 8.67.0 client identity.

Testing

  • Typecheck and docs build pass.
  • Checked against the live API: search with filters and facets, location lookup, application token fetch, category tree, and ad detail.
  • With a logged-in session: whoami, list, get, images, and token refresh. The refresh stores the rotated token and a second refresh with it works.
  • list and get report the same status for all listings on a test account.
  • publish --draft with an image created a draft with its photo. It wasn't publicly searchable.
  • Not tested: activate, update, and publishing without --draft.

- Add `search` command for marketplace listings with price, state,
  seller, PayLivery, recency, sort and raw facet filters (no login needed)
- Add `locations` command to look up location ids for a postcode
- `publish` resolves locationId from postCode/location; drop incorrect
  location ids from the docs
- Store the rotated refresh token on refresh so sessions stay alive, and
  report an expired session instead of failing with 401
- `whoami` shows whether the session is active
- `get` and `categories` work without login
- Centralize client headers and update to the Android 8.67.0 identity
Both endpoints return the same numeric ad status, but list and get mapped
it differently and neither knew sold (120), so sold ads showed as active
or inactive. Map the status id in one place and add draft, pending,
rejected and sold.
publish now saves the listing, uploads the template's images, and only
then puts it live, so a listing never goes live without its photos. If
an upload fails, the listing stays a draft. --draft was accepted but
ignored; it now keeps the listing as a draft, and the new `activate`
command puts it live.
@tomLadder
tomLadder merged commit 9081cf8 into main Oct 30, 2026
1 check passed
@tomLadder
tomLadder deleted the feat/search-locations-session-fix branch October 30, 2026 10:25
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