Open
Conversation
Invoice already has an `errors` field, but LineItem and Transaction did not. Add `errors = fields.Dict(allow_none=True)` to both schemas so validation errors returned by the API are accessible on nested objects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `id` field to Account schema so the account identifier is accessible. Add `churn_recognition` and `churn_when_zero_mrr` fields to support the optional `include` query parameter on the /account endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Invoice.update_status (PATCH /invoices/{uuid}) for updating invoice
status and Invoice.disable (PATCH /invoices/{uuid}/disable) for
disabling invoices.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add SubscriptionEvent.destroy() and .modify() that accept flat params
(e.g. data={"id": 123}) and auto-wrap in the subscription_event
envelope. The old _with_params methods are preserved for backwards
compatibility.
Add SubscriptionEvent.disable() and .enable() convenience methods
for toggling the disabled state of subscription events.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add edge case, error path, and backwards-compatibility tests: Invoice: - Verify update_status request body is sent correctly - 404 error paths for update_status and disable - Verify disable sends no request body - LineItem/Transaction errors=None and errors-absent cases SubscriptionEvent: - Flat destroy/modify with external_id+data_source_uuid - Passthrough when caller already wraps in envelope (no double-wrap) - disable/enable with external_id+data_source_uuid identification Account: - Graceful handling when id field absent from response - Single include param Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@claude review |
Contributor
Author
|
@claude review |
There was a problem hiding this comment.
Pull request overview
This PR updates the Python SDK to support additional API response fields and adds/adjusts client methods for invoice and subscription event operations, with accompanying test coverage.
Changes:
- Add deserialization support for
errorson invoice line items/transactions and for additional account fields (id, churn settings). - Add invoice endpoints for updating status and disabling invoices.
- Add
SubscriptionEvent.destroy/modify/disable/enablehelpers that accept “flat” params and wrap them in the requiredsubscription_eventenvelope, plus tests for these behaviors.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
chartmogul/api/transaction.py |
Adds errors field support on Transaction schema. |
chartmogul/api/invoice.py |
Adds errors support on invoice-related schemas and introduces update_status / disable methods. |
chartmogul/api/account.py |
Extends Account schema with optional id and churn-related fields. |
chartmogul/api/subscription_event.py |
Adds wrapper methods to accept flat params and to enable/disable subscription events. |
test/api/test_invoice.py |
Adds tests for nested errors fields and new invoice status/disable endpoints. |
test/api/test_account.py |
Adds tests for newly supported account fields and include query behavior. |
test/api/test_subscription_event.py |
Adds tests for flat-parameter wrapping and enable/disable helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| ) | ||
| Invoice.retrieve = Invoice._method("retrieve", "get", "/invoices{/uuid}") | ||
| Invoice.update_status = Invoice._method("modify", "patch", "/invoices{/uuid}") | ||
| Invoice.disable = Invoice._method("patch", "patch", "/invoices{/uuid}/disable") |
Comment on lines
+72
to
+85
| data = kwargs.get("data", {}) | ||
| data["disabled"] = True | ||
| if "subscription_event" not in data: | ||
| data = {"subscription_event": data} | ||
| return cls.modify_with_params(config, data=data) | ||
|
|
||
|
|
||
| @classmethod | ||
| def _enable(cls, config, **kwargs): | ||
| """Enable a subscription event by setting disabled to false.""" | ||
| data = kwargs.get("data", {}) | ||
| data["disabled"] = False | ||
| if "subscription_event" not in data: | ||
| data = {"subscription_event": data} |
Comment on lines
+72
to
+85
| data = kwargs.get("data", {}) | ||
| data["disabled"] = True | ||
| if "subscription_event" not in data: | ||
| data = {"subscription_event": data} | ||
| return cls.modify_with_params(config, data=data) | ||
|
|
||
|
|
||
| @classmethod | ||
| def _enable(cls, config, **kwargs): | ||
| """Enable a subscription event by setting disabled to false.""" | ||
| data = kwargs.get("data", {}) | ||
| data["disabled"] = False | ||
| if "subscription_event" not in data: | ||
| data = {"subscription_event": data} |
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.
No description provided.