Repository navigation
feat: add Target provider - #110
Merged
Merged
Conversation
Syncs Target in-store receipts (linked to Target Circle) and online orders. Target has no public API, so the provider uses the JSON APIs target.com's own order pages call, through github.com/daslicious/target-go (client, session handling, field notes in its PROTOCOL.md). - Login: a DevTools "Copy as cURL" of the orders page's history request, saved with `itemize target set-session -account <name>` after Target accepts it. Each run renews the 24-hour access token first and saves the rotated refresh token at once (shared lock file, so other tools can use the login). - Card charges: receipts match their card tenders; reusable-bag discounts, gift cards and manufacturer coupons are left out. An online order charged once per shipment becomes one order per charge (<order>, <order>-2, ...), priced from its invoice lines. Cancelled items and orders paid entirely by gift card are left out. - Items carry Target's unit price, quantity and product type; the Circle Card 5% and tax are spread by the splitter. Items Target sends without a name take it from the history entry; otherwise the order fails and is retried later. - Commands: `itemize target` (sync), `target orders` (JSON, no Monarch), `target refresh`, `target set-session`. Also registered for `itemize serve`. - Errors scripts can match: `target auth check failed`, `target blocked the request` (bot protection; requests are paced 3-5 s). Checked against two years of one household's Target history (94 online orders, 50 receipts): 142 of 143 posted orders and charges match a bank transaction to the cent. Test fixtures keep Target's response shapes with made-up ids, stores, dates and items. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
==========================================
+ Coverage 66.12% 66.88% +0.76%
==========================================
Files 51 53 +2
Lines 7164 7453 +289
==========================================
+ Hits 4737 4985 +248
- Misses 2081 2111 +30
- Partials 346 357 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Adds
itemize target: syncs Target in-store receipts (those linked to Target Circle) and online orders into Monarch, like the other providers.How it works
Target has no public API, so the provider uses the JSON APIs that target.com's own order pages call. The client is a separate module, daslicious/target-go (MIT), in the same way costco-go and walmart-client-go are separate. Its PROTOCOL.md documents the endpoints, login renewal and how orders map to card charges.
historyrequest as cURL, and pipe it toitemize target set-session -account <name>. The login is saved only if Target accepts the replayed request. Before each run, the 24-hour access token is renewed and the rotated refresh token is saved immediately. The refresh token lasts 180 days, and the session file is shared under a lock file. The README section has the steps.<order>,<order>-2, …), priced from that charge's invoice lines. Cancelled items, and orders paid entirely by gift card, are left out.itemize target(sync),target orders(prints orders as JSON, no Monarch),target refresh,target set-session. Target is also registered foritemize serve, using thedefaultlogin.target auth check failed(expired login) andtarget blocked the request(bot protection). Requests are paced 3–5 s apart.Testing
go test -race ./...passes. golangci-lint v2.14.0 reports 0 issues.Notes for review
internal/instead.ITEMIZE_TARGET_DIR, defaulting to~/.itemize/target, the same convention as~/.itemize/amazon. I'm happy to move it intoconfig.yaml.🤖 Generated with Claude Code