You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MPT-21666 stream statement charges as JSONL (#333)
π€ AI-generated PR β Please review carefully.
## What was done
Add line-by-line JSONL/NDJSON streaming for statement charges so large
charge sets can be consumed without buffering full pages into memory.
- Add a `stream()` context-manager primitive to
`HTTPClient`/`AsyncHTTPClient` that opens a streaming response (`Accept:
application/jsonl`) and follows the redirect to the charge blob
automatically.
- Add `StreamJSONLMixin`/`AsyncStreamJSONLMixin` that iterate the
response lines and yield one parsed model per line; wire it into
`StatementChargesService`, exposing
`client.billing.statements.charges(id).stream()`.
- Populate the `StatementCharge` model with the full Charge schema
fields from the MPT OpenAPI spec (typed scalars + nested `BaseModel`
refs).
- Add unit and e2e coverage; ignore `.claude/` local artifacts.
## Testing
Unit and e2e coverage added for the streaming primitive, the JSONL
mixins, and the statement charges service.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
Closes [MPT-21666](https://softwareone.atlassian.net/browse/MPT-21666)
- Add JSONL/NDJSON streaming for statement charges to stream large
charge sets without buffering full pages
- Introduce HTTPClient.stream and AsyncHTTPClient.stream context
managers that open streaming responses with Accept: application/jsonl
and follow charge-blob redirects
- Add StreamJSONLMixin and AsyncStreamJSONLMixin to iterate JSONL
response lines and yield one parsed model per line
- Wire streaming mixins into StatementChargesService and
AsyncStatementChargesService so callers can use
client.billing.statements.charges(id).stream()
- Expand StatementCharge model with full Charge schema fields (typed
scalars and nested BaseModel references)
- Add unit and end-to-end tests for the streaming primitives, JSONL
mixins, and statement charges service
- Update .gitignore to ignore local .claude/ artifacts
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
[MPT-21666]:
https://softwareone.atlassian.net/browse/MPT-21666?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
0 commit comments