Skip to content

Add ExcludedCustomer resource and exclude option on customer delete - #203

Merged
ya-petrov-evgeniy merged 2 commits into
mainfrom
evgenii/excluded-customers
Nov 30, 2026
Merged

ya-petrov-evgeniy merged 2 commits into
mainfrom
evgenii/excluded-customers

Conversation

@ya-petrov-evgeniy

@ya-petrov-evgeniy ya-petrov-evgeniy commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Adds client support for the exclude customers API (PIP-585), shipped in chartmogul/platform#33735 and chartmogul/platform#33795.

Added

  • Customer.destroy!(uuid:, exclude: true) and Customer#destroy!(exclude: true) send exclude=true on DELETE /v1/customers/:uuid, which also puts the customer on the account's exclude list so it is not re-imported. Without exclude the request is unchanged, with no query params.
  • ChartMogul::ExcludedCustomer / ChartMogul::ExcludedCustomers for /v1/excluded_customers:
    • ExcludedCustomer.all(cursor:, per_page:) lists excluded customers with cursor pagination (cursor, has_more, #next). Entries expose customer_uuid, data_source_uuid, external_id, name, email and excluded_at (parsed to Time).
    • ExcludedCustomer.reinclude!(customer_uuid) and ExcludedCustomer#reinclude! call DELETE /v1/excluded_customers/:customer_uuid and return a ChartMogul::ReincludedCustomer with only customer_uuid and status (reimporting or manual_reimport_required). The instance form leaves the list entry unchanged. A customer that is not excluded raises ChartMogul::NotFoundError.
  • ChartMogul::ReincludedCustomer: the re-include result. It is kept separate from the list entry type because the response has none of the entry's other fields, and list entries have no status.

The re-include method is named reinclude! rather than destroy! because it returns a status instead of true, and so it can't be mistaken for deleting the customer. The name and the separate ReincludedCustomer type match the other ChartMogul SDKs.

Tests

  • WebMock specs (VCR off) cover: exclude=true sent from the class and instance delete; no query params without it; list query params, entry parsing, cursor/has_more and #next; a ReincludedCustomer with the status from both forms (the instance form leaves the entry unchanged); list entries having no status; and 404 on re-include.
  • Mutation-checked: dropping or always sending exclude, dropping it on the instance path, the wrong HTTP verb, returning true from #reinclude!, returning an ExcludedCustomer instead of a ReincludedCustomer, adding status back to list entries, removing status from the result, removing cursor pagination and leaving excluded_at untyped each break at least one spec.
  • bundle exec rake: 423 examples, 0 failures. Rubocop shows no new kinds of offense: the new files only have the Style/Documentation and spec Metrics/BlockLength offenses that existing resources also have.
  • I didn't record VCR cassettes against a live account.
  • Tested end-to-end against a local API (platform main with chartmogul/platform#33735 and #33795, custom data source with exclude_customers on), with ChartMogul.api_base pointed at it. Created two customers, then deleted A with exclude: true and B without it. Followed ExcludedCustomer.all(per_page: 1) through every page: A was listed with all fields correct and excluded_at parsed to a Time, and B was not listed. reinclude! on A returned a ReincludedCustomer with manual_reimport_required, a second reinclude! raised NotFoundError (404), and A was gone from the list afterwards.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ya-petrov-evgeniy
ya-petrov-evgeniy requested review from keith-chartmogul and tudorpavel and removed request for tudorpavel November 25, 2026 08:24
@ya-petrov-evgeniy
ya-petrov-evgeniy marked this pull request as ready for review November 25, 2026 08:24
Comment thread lib/chartmogul/excluded_customer.rb Outdated
readonly_attr :name
readonly_attr :email
readonly_attr :excluded_at, type: :time
readonly_attr :status

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May be deliberate to keep things simple, but leaving this here just in case we want to be more explicit in some of the SDKs.

Ruby, Python and PHP put the re-include result in the same class as a list entry. status exists only on the re-include response, and that response lacks the other fields. In Python, reading .name on a re-include result raises AttributeError. Go avoids this with a separate ReincludedCustomer type.

@ya-petrov-evgeniy ya-petrov-evgeniy Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, reinclude! now returns a separate ReincludedCustomer with only customer_uuid and status.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ya-petrov-evgeniy
ya-petrov-evgeniy merged commit e93277a into main Nov 30, 2026
7 checks passed
@ya-petrov-evgeniy
ya-petrov-evgeniy deleted the evgenii/excluded-customers branch November 30, 2026 07:02
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.

3 participants