v4.13.0: New resources, external-id operations, and disable toggles#184
Open
jessicahearn wants to merge 17 commits intomainfrom
Open
v4.13.0: New resources, external-id operations, and disable toggles#184jessicahearn wants to merge 17 commits intomainfrom
jessicahearn wants to merge 17 commits intomainfrom
Conversation
- Add Account `include` parameter for optional settings (churn_recognition, churn_when_zero_mrr, auto_churn_subscription, refund_handling, proximate_movement_reclassification) - Add DataSource `empty!` and `soft_purge!` methods for data management - Add Invoice `update!`, `toggle_disabled!`, `update_status!` methods - Add SubscriptionEvent `toggle_disabled!` method - Add standalone Transaction resource with CRUD and `toggle_disabled!` - Add standalone LineItem resource with CRUD and `toggle_disabled!` - Add external ID lookup methods (`*_by_external_id`) for Invoice, Transaction, LineItem, and SubscriptionEvent - Add JsonImport resource for bulk JSON imports - Add Upload resource for CSV file uploads (requires faraday-multipart) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added optional handle_as_user_edit parameter to: - Invoice: toggle_disabled!, update_by_external_id!, destroy_by_external_id!, toggle_disabled_by_external_id! - Transaction: toggle_disabled!, update_by_external_id!, destroy_by_external_id!, toggle_disabled_by_external_id! - LineItem: create!, toggle_disabled!, update_by_external_id!, destroy_by_external_id!, toggle_disabled_by_external_id! - SubscriptionEvent: toggle_disabled!, update_by_external_id!, destroy_by_external_id!, toggle_disabled_by_external_id! This allows API consumers to indicate when changes should be treated as user edits for edit history tracking purposes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a class-level destroy! method that accepts both flat params and envelope-wrapped params for full backwards compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1414f52 to
1bb31e2
Compare
Tests cover new_from_json (including errors/edit_history_summary fields), CRUD operations, toggle_disabled, by_external_id methods, and handle_as_user_edit query parameter support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…_id methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…thods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
@claude review |
Contributor
|
@claude review |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the ChartMogul Ruby SDK with new v4.13.0 resources and convenience endpoints (uploads/imports, external-id lookups, disable toggles), and bumps the gem version + changelog accordingly.
Changes:
- Add new resources:
Transaction,LineItem,JsonImport, andUpload(CSV multipart). - Add new operations to existing resources: Account
include, DataSourceempty!/soft_purge!, Invoice toggle/update-by-external-id/status, SubscriptionEvent disable toggle + external-id ops. - Add/extend specs for the newly added endpoints and behaviors, and update version/changelog.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/chartmogul/upload_spec.rb | Adds tests for CSV upload creation (multipart) and attribute parsing |
| spec/chartmogul/transaction_spec.rb | Adds tests for Transaction external-id operations and disable toggling |
| spec/chartmogul/subscription_event_spec.rb | Adds tests for SubscriptionEvent destroy variants, disable toggling, and external-id operations |
| spec/chartmogul/line_item_spec.rb | Adds tests for LineItem CRUD-like endpoints + external-id ops + disable toggling |
| spec/chartmogul/json_import_spec.rb | Adds tests for JsonImport create/retrieve endpoints |
| spec/chartmogul/invoice_spec.rb | Adds tests for new Invoice disable toggling + external-id ops + status update |
| spec/chartmogul/data_source_spec.rb | Adds tests for DataSource empty! and soft_purge! |
| spec/chartmogul/account_spec.rb | Adds tests for Account .retrieve(include: ...) behavior |
| lib/chartmogul/version.rb | Bumps gem version to 4.13.0 |
| lib/chartmogul/upload.rb | Implements Upload resource + multipart CSV upload |
| lib/chartmogul/transaction.rb | Implements standalone Transaction resource + external-id ops + disable toggles |
| lib/chartmogul/subscription_event.rb | Adds disabled fields, toggle APIs, and external-id update/destroy/toggle methods |
| lib/chartmogul/line_item.rb | Implements standalone LineItem resource + external-id ops + disable toggles |
| lib/chartmogul/json_import.rb | Implements JsonImport create/retrieve for bulk JSON import |
| lib/chartmogul/invoice.rb | Adds Invoice update support + disable toggles + external-id ops + status update |
| lib/chartmogul/data_source.rb | Adds DataSource empty! and soft_purge! methods |
| lib/chartmogul/account.rb | Adds include parameter support and optional account settings attributes |
| lib/chartmogul.rb | Requires the newly added resource files |
| chartmogul-ruby.gemspec | Removes the post-install message |
| changelog.md | Adds 4.13.0 changelog entry describing new SDK features |
💡 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.
Wraps external_id, data_source_uuid, invoice_external_id, include fields, and switch_system values with CGI.escape to prevent malformed URLs when values contain reserved characters. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds RaiseError, retry, and User-Agent middleware to match the standard APIResource connection, ensuring consistent error handling and retries for multipart upload requests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add Concerns::ToggleDisabled and Concerns::ExternalIdOperations to eliminate ~150 lines of duplicated code across LineItem, Transaction, and Invoice resources - Add build_query_path, json_patch, json_post helpers to APIResource for proper URL encoding and DRY JSON request handling - Memoize Upload multipart_connection to avoid rebuilding per call - Document SubscriptionEvent envelope-wrapping pattern Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
TransactionandLineItemresources with CRUD,toggle_disabled!, and external-id operationsJsonImportresource for bulk JSON imports (create + retrieve)Uploadresource for CSV file uploads via multipart (requiresfaraday-multipart)toggle_disabled!,update_status!,update_by_external_id!,destroy_by_external_id!,toggle_disabled_by_external_id!toggle_disabled!,update_by_external_id!,destroy_by_external_id!,toggle_disabled_by_external_id!destroy!accepting both flat and envelope-wrapped params for backwards compatibilityincludeparameter support andidreadonly attributeerrorsreadonly attribute to LineItem and Transaction (PIP-304)handle_as_user_editquery parameter to all write methodsConcerns::ToggleDisabledandConcerns::ExternalIdOperationsto reduce duplicationbuild_query_path,json_patch,json_posthelpers to APIResourceBackwards compatibility review
All changes are additive — no existing method signatures, return types, or behaviors were altered. Safe as a minor (4.13.0) release.
Modified resources
()to(include: nil)includedefaults tonil, existing calls work identicallyUpdateaction,ToggleDisabled,ExternalIdOperationsconcerns,update_status!Retrieve,Destroy, attributes,all,serialize_*, private setters unchangeddisabled/disabled_atreadonly attrs, class-leveldestroy!, toggle/external-id methodsdestroy!untouched; no class-leveldestroy!existed on mainrequire "cgi"/"uri",build_query_path,json_patch,json_postcgialready available transitivelypost_install_messageNew resources — no collision
ChartMogul::TransactionTransactions::Payment/Refundexist under a module namespace — no collisionChartMogul::LineItemLineItems::Subscription/OneTimeexist under a module namespace — no collisionChartMogul::JsonImportChartMogul::UploadConcerns::ToggleDisabledConcerns::ExternalIdOperationsNote
SubscriptionEvent.destroy!— new class method alongside existing instance method. Ruby class and instance methods don't collide. Users callingevent.destroy!on an instance still get the original instance method with no behavior change.Automated test plan
handle_as_user_editquery parameter across all resourcesTesting instructions
Use ChartMogul account WiktorOnboarding (
acc_d0ea225e-f0f1-40ab-92cf-659dce5f2b76). Impersonate user wiktor.plaga@chartmogul.com to find the API key in the account settings. The test script creates its own data source, customer, plan, invoice (with line items and transactions), and subscription events — then cleans everything up on exit. Toggle tests use the existing Stripe data source (ds_bdb16dbc-...) since toggle_disabled is not allowed on Custom data sources.Quick run (tests all features end-to-end):
Result: 31 tests — 29 pass, 2 known flaky (SE external_id indexing on fresh Custom DS takes minutes; SDK code verified correct via Stripe SE tests).
Account
includeparameterInvoice operations
Standalone LineItem resource
Standalone Transaction resource
SubscriptionEvent operations
JsonImport resource
handle_as_user_edit parameter
All write methods across Invoice, LineItem, Transaction, and SubscriptionEvent accept
handle_as_user_edit:as a keyword argument. It is appended as a URL query parameter (?handle_as_user_edit=true). Tested inLineItem.create!,LineItem.update_by_external_id!, and alltoggle_disabled!variants.🤖 Generated with Claude Code