Repository navigation
WIP: feat(opportunities): EbuyOpportunity for eBuy rows and UpstreamWarnings on the page - #22
Draft
makegov-hal[bot] wants to merge 1 commit into
Draft
makegov-hal[bot] wants to merge 1 commit into
makegov-hal[bot] wants to merge 1 commit into
Conversation
…gs on the page ListOpportunities already returns every row as a raw Record, so rows are unchanged. EbuyOpportunityFromRecord decodes a row whose domain is "ebuy" into a typed EbuyOpportunity (unrecognized keys in Extra) and reports false for any other row. PaginatedResponse gains UpstreamWarnings, read from the envelope's upstream_warnings; Count handling is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
ListOpportunitiesalready returns every row as a rawRecord, so nothing about existing rows changes. This adds a typedEbuyOpportunityplus a helper that picks eBuy rows out of an opportunities page, and addsUpstreamWarningstoPaginatedResponseso a combinedsam,ebuylisting can say which parts it couldn't include in the page.Changes
opportunities.go: newEbuyOpportunitystruct with the eBuy listing's 14 named fields (Domainas a plainstring, the other 13 as*string, withPostedAtandClosesAtkept as the ISO 8601 strings the API sent, matching the repo's other typed models), andExtra map[string]anyfor unrecognized keys.EbuyOpportunityFromRecord(r Record) (EbuyOpportunity, bool)returnsfalsefor any row whosedomainisn't"ebuy"(SAM rows, rows with nodomainkey, andnil). It never fails or panics: a named field whose value is neither a string nor null goes toExtrainstead of being dropped.UnmarshalJSONshares that decoding. Godoc onListOpportunitiesandIterateOpportunitiesexplains which rows are eBuy rows, that the API ignoresshapewhendomainincludesebuy, the combined listing's row order, and how a nullcountreads inCount.pagination.go:PaginatedResponse.UpstreamWarnings []string, decoded indecodePaginatedfrom the envelope'supstream_warnings. It keeps only the string entries and is nil when the key is absent, null, empty, or not a list, so a malformed value never fails the page.Counthandling is untouched.docs/API_REFERENCE.md(list-response fields, plus a section underListOpportunitieswith an example),docs/ARCHITECTURE.md(envelope fields), andREADME.md(pagination note and the opportunities row of the methods table).CHANGELOG.md: two### Addedbullets under[Unreleased]. No version bump.Testing
gofmt -s -l .: no files listed.go vet ./...: clean.go test -race -coverprofile=coverage.out ./...: all packages pass; root package coverage is 95.4%, and the newEbuyOpportunityFromRecord,ebuyOpportunityFromMap, anddecodeUpstreamWarningsare each at 100%.golangci-lint run ./...(v1.64.8, repo.golangci.yml): clean. The pre-commit and pre-push hooks passed as well.New tests, all against a mocked HTTP response:
opportunities_ebuy_test.go: an eBuy-only page decodes every named field, keeps the datetimes as strings, and putsnew_fieldinExtra. A combined page keeps both SAM rows raw (domain: "sam",notice_id, a nestedoffice, andsam_urlintact despite a narrowershape), decodes the eBuy row with its nulls, preserves order, readsUpstreamWarnings, and reports a nullcountas the row count. A plain page with nodomainkey comes back exactly as before. The helper rejects nil, no-domain, SAM, null-domain, and numeric-domain rows. It keeps a wrongly typed named field inExtra.json.UnmarshalintoEbuyOpportunityworks, andIterateOpportunitiesyields eBuy rows.pagination_test.go:UpstreamWarningswhen present, absent, null, an empty list, a list with non-string entries, and not a list.Notes
Domainfield toListOpportunitiesOptions. That field lands in WIP: feat(opportunities): add the Domain filter to ListOpportunitiesOptions #21, which makes eBuy rows reachable through a named option. Until then,Extra: map[string]any{"domain": "sam,ebuy"}sends the same query parameter.### Addedsection under[Unreleased]inCHANGELOG.md, so whichever merges second needs a trivial merge of that section. The other files don't overlap.(EbuyOpportunity, bool)rather than an error because its decode can't fail. Every named field is a string or null, and anything else is kept inExtra.🤖 Generated with Claude Code