Add SubscriptionEvent wrapping/disable/enable and Invoice updateStatus/disable [PIP-311]#129
Open
Add SubscriptionEvent wrapping/disable/enable and Invoice updateStatus/disable [PIP-311]#129
Conversation
…passing bug - Wrap flat params in `subscription_event` envelope for create/update/delete - Add disable/enable state toggling endpoints - Fix bug where undefined callback arg blocked data extraction in _method() - Add tests verifying body wrapping and error handling Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Invoice.updateStatus (PATCH /v1/invoices/:uuid) - Add Invoice.disable (PATCH /v1/invoices/:uuid/disable) - Add tests for happy path, callback style, body params, and error cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the ChartMogul Node SDK to support newer API behaviors for Subscription Events, Invoices, and Account retrieval by adding/adjusting client methods and expanding test coverage for these behaviors.
Changes:
- Add support for flat (non-enveloped) SubscriptionEvent params by auto-wrapping into a
subscription_eventenvelope, while keeping backward compatibility for already-enveloped inputs. - Add
SubscriptionEvent.enable/disableandInvoice.updateStatus/disableSDK methods and corresponding tests. - Expand invoice/account test fixtures and assertions to cover new/optional response fields (e.g.,
error,id, and accountincludequery param).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
lib/chartmogul/subscription_event.js |
Adds param-wrapping overrides for create/update/delete and adds enable/disable endpoints. |
lib/chartmogul/invoice.js |
Adds PATCH helpers for invoice status updates and invoice disable endpoint. |
test/chartmogul/subscription-event.js |
Updates tests to validate envelope wrapping + adds enable/disable tests and negative cases. |
test/chartmogul/invoice.js |
Adds tests for invoice status updates/disable + extends fixtures with error fields. |
test/chartmogul/account.js |
Adds assertions for id and supports include query param + negative case. |
💡 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.
- Use hasOwnProperty check in wrapParams to handle falsy envelope values - Use typeof callback === 'function' instead of truthy check Co-Authored-By: Claude Opus 4.6 (1M context) <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
Closes PIP-311
subscription_eventenvelope for create/update/delete, with backward compatibility for already-enveloped inputsSubscriptionEvent.disable/SubscriptionEvent.enableendpointsundefinedcallback to_method()blocked request body from being sentInvoice.updateStatusandInvoice.disableendpointsincludequery paramTest plan
npm test)Manual testing instructions
1. SubscriptionEvent — flat params auto-wrapping (create)
Previously you had to wrap params in
{ subscription_event: { ... } }. Now flat params work too.✅ Expected: Both calls succeed and return the created subscription event.
2. SubscriptionEvent — flat params auto-wrapping (update)
✅ Expected: Both calls succeed and return the updated subscription event.
3. SubscriptionEvent — flat params auto-wrapping (delete)
✅ Expected: Both calls succeed with empty response
{}.4. SubscriptionEvent — disable / enable
✅ Expected: Disable returns
disabled: true, enable returnsdisabled: false, nonexistent ID returns 404.5. Invoice — updateStatus
✅ Expected: Valid status update succeeds, invalid status returns 422.
6. Invoice — disable
✅ Expected: Disable succeeds with
disabled: true+ timestamps, nonexistent UUID returns 404.🤖 Generated with Claude Code