feat: add Home Depot provider#77
Open
fnziman wants to merge 1 commit into
Open
Conversation
Adds a new `homedepot` subcommand that syncs Home Depot purchases into Monarch, mirroring the walmart/costco/amazon providers. Design (per proposal in eshaffer321#31): - Companion Go client github.com/fnziman/homedepot-go handles the internal /oms/customer/order/v1 API via cookie replay (THD_CUSTOMER cookie decoded for the auth token). itemize depends on tagged release v0.1.1. - Provider adapter at internal/adapters/providers/homedepot/ wraps the client's OrderDetail + LineItem types to satisfy providers.Order + providers.OrderItem. - Both online and in-store schemas supported. Online orders use orderNumber as the dedup ID; in-store use a composite hd-instore-{store}-{transactionId} since orderNumber is empty. Registration: - internal/cli/providers.go: NewHomeDepotProvider — mirrors the costco/walmart factory shape, threads a scoped *slog.Logger through to homedepot-go. - cmd/itemize/main.go: `case "homedepot":` in the subcommand switch; printUsage rows for the command and the HOMEDEPOT_* env vars. - internal/infrastructure/config/config.go: HomeDepotConfig struct, env-var defaults in LoadFromEnv (HOMEDEPOT_LOOKBACK_DAYS, HOMEDEPOT_MAX_ORDERS, HOMEDEPOT_COOKIE_FILE). - config.yaml: `homedepot:` block. Merchant matching: no interface change needed. fetch.go matches against DisplayName(), which is "Home Depot" — case-insensitive substring-matches Monarch's "THE HOME DEPOT" cleanly. Tests: 95.1% coverage on the provider package. Mock hdClient interface; every FetchOrders / GetOrder / HealthCheck / GetItems / GetSKU / GetQuantity path tested. All Order/OrderItem interface compliance asserted at compile time. Docs: README provider row + full walkthrough at docs/homedepot-specifics.md (cookie export, MFA re-auth, 24-month history cap, troubleshooting table). Attribution to joshellissh/homedepot-history in the client's README. Refs eshaffer321#31 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
==========================================
+ Coverage 64.34% 65.06% +0.71%
==========================================
Files 49 51 +2
Lines 6575 6761 +186
==========================================
+ Hits 4231 4399 +168
- Misses 2037 2046 +9
- Partials 307 316 +9
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 a new
homedepotsubcommand that syncs Home Depot purchases into Monarch, mirroring the walmart/costco/amazon providers.Closes / references #31. Design follows the plan you signed off on in that thread.
Design
github.com/fnziman/homedepot-go— MIT, tagged release v0.1.1 — handles the internal/oms/customer/order/v1/user/{userId}/orderhistory+/orderdetailsendpoints via cookie replay (decodesTHD_CUSTOMERfor the auth token). The client itself is scrubbed-fixtures-only (no real cookies/tokens/PII), 85.6% covered,go 1.25.12to match this repo's CI pin.internal/adapters/providers/homedepot/. Wraps the client'sOrderDetail/LineItemtypes to satisfyproviders.Order/providers.OrderItem. Both online and in-store orders supported. Online orders useorderNumberas the dedup ID; in-store use a compositehd-instore-{store}-{transactionId}(sinceorderNumberis empty for in-store).internal/cli/providers.go:NewHomeDepotProvider(mirrors the costco/walmart shape, threads a scoped*slog.Loggerviahdgo.Config{Logger: hdLogger}— matches the walmart/costcoConfig-struct pattern per your ask), newcase "homedepot":incmd/itemize/main.go,HomeDepotConfiginconfig.go,homedepot:block inconfig.yaml, env-var fallbacks (HOMEDEPOT_LOOKBACK_DAYS,HOMEDEPOT_MAX_ORDERS,HOMEDEPOT_COOKIE_FILE).fetch.gomatches onDisplayName()which is"Home Depot"— that case-insensitively substring-matches Monarch's canonical"THE HOME DEPOT".SupportsRefunds() = false; refund handling can go in a follow-up.Test plan
go test ./... -race— all green, provider package at 95.1% coverage, categorizer/adapter packages unchangedgo vet ./...— cleangolangci-lint run ./...— clean for touched files (two pre-existingQF1012warnings oncategorizer.go:285,290predate this PR)go build -o itemize ./cmd/itemize/—./itemizeshowshomedepot Sync Home Depot ordersin usage andHOMEDEPOT_*env vars in helpgo.modstays ongo 1.25.12(verified aftergo mod tidy)HOMEDEPOT_COOKIE_FILE=~/.homedepot-api/cookies.json ./itemize homedepot -dry-run -days 14 -verbose— happy to run this and report back once you've had a chance to look at the codeDocs
homedepotrow + example usagedocs/homedepot-specifics.mdcovers cookie export walkthrough (DevTools snippet), the online/in-store distinction, 24-month history cap, MFA re-auth flow, and a troubleshooting tableDeferred / follow-ups (not in this PR per your "keep it focused" note)
OrderDetail.returnTotalis available; just not wired)LICENSEfile on this repodocs/adding-providers.mdrefresh (still references the pre-rename module path andinternal/providers/)Happy to iterate — let me know if you'd like any part of this reshaped before merge.