Skip to content

WIP: feat(opportunities): EbuyOpportunity for eBuy rows and UpstreamWarnings on the page - #22

Draft
makegov-hal[bot] wants to merge 1 commit into
mainfrom
feat/ebuy-opportunity-rows
Draft

makegov-hal[bot] wants to merge 1 commit into
mainfrom
feat/ebuy-opportunity-rows

Conversation

@makegov-hal

@makegov-hal makegov-hal Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Summary

ListOpportunities already returns every row as a raw Record, so nothing about existing rows changes. This adds a typed EbuyOpportunity plus a helper that picks eBuy rows out of an opportunities page, and adds UpstreamWarnings to PaginatedResponse so a combined sam,ebuy listing can say which parts it couldn't include in the page.

Changes

  • opportunities.go: new EbuyOpportunity struct with the eBuy listing's 14 named fields (Domain as a plain string, the other 13 as *string, with PostedAt and ClosesAt kept as the ISO 8601 strings the API sent, matching the repo's other typed models), and Extra map[string]any for unrecognized keys. EbuyOpportunityFromRecord(r Record) (EbuyOpportunity, bool) returns false for any row whose domain isn't "ebuy" (SAM rows, rows with no domain key, and nil). It never fails or panics: a named field whose value is neither a string nor null goes to Extra instead of being dropped. UnmarshalJSON shares that decoding. Godoc on ListOpportunities and IterateOpportunities explains which rows are eBuy rows, that the API ignores shape when domain includes ebuy, the combined listing's row order, and how a null count reads in Count.
  • pagination.go: PaginatedResponse.UpstreamWarnings []string, decoded in decodePaginated from the envelope's upstream_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. Count handling is untouched.
  • Docs: docs/API_REFERENCE.md (list-response fields, plus a section under ListOpportunities with an example), docs/ARCHITECTURE.md (envelope fields), and README.md (pagination note and the opportunities row of the methods table).
  • CHANGELOG.md: two ### Added bullets 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 new EbuyOpportunityFromRecord, ebuyOpportunityFromMap, and decodeUpstreamWarnings are 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 puts new_field in Extra. A combined page keeps both SAM rows raw (domain: "sam", notice_id, a nested office, and sam_url intact despite a narrower shape), decodes the eBuy row with its nulls, preserves order, reads UpstreamWarnings, and reports a null count as the row count. A plain page with no domain key 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 in Extra. json.Unmarshal into EbuyOpportunity works, and IterateOpportunities yields eBuy rows.
  • pagination_test.go: UpstreamWarnings when present, absent, null, an empty list, a list with non-string entries, and not a list.

Notes

🤖 Generated with Claude Code

…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>
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