Skip to content

Wiktor/pip 310 python sdk feature updates#129

Open
wscourge wants to merge 5 commits intomainfrom
wiktor/pip-310-python-sdk-feature-updates
Open

Wiktor/pip 310 python sdk feature updates#129
wscourge wants to merge 5 commits intomainfrom
wiktor/pip-310-python-sdk-feature-updates

Conversation

@wscourge
Copy link
Contributor

No description provided.

wscourge and others added 5 commits March 17, 2026 17:04
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>
@wscourge
Copy link
Contributor Author

@claude review

@wscourge wscourge marked this pull request as ready for review March 17, 2026 16:16
@wscourge
Copy link
Contributor Author

@claude review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 errors on 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/enable helpers that accept “flat” params and wrap them in the required subscription_event envelope, 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}
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.

2 participants