Skip to content

ENGL-663: Catch up the Ruby SDK with the public API - #41

Merged
kavanpancholi merged 9 commits into
mainfrom
feature/engl-663-catch-up-the-ml-sdks-with-the-public-api-subscribers-groups
Nov 3, 2026
Merged

kavanpancholi merged 9 commits into
mainfrom
feature/engl-663-catch-up-the-ml-sdks-with-the-public-api-subscribers-groups

Conversation

@kavanpancholi

@kavanpancholi kavanpancholi commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Why?

The Ruby SDK was behind the public API. It could read automations but not build, change or control them. Some list calls also sent their params where the API never reads them. This catches it up with every subscribers, groups, segments, fields and automations endpoint on ENGL-663, and fixes the known Ruby bugs from the card.

Changes

  1. Known bugs fixed:
    • Groups#get_subscribers and Segments#list sent their params as a JSON body on a GET, so the API ignored them. They now go in the query string.
    • Automations#get_subscriber_activity sent filter[keyword], which the API rejects with a 400. It now sends the documented filter[search]. An old filter[:keyword] value is sent as filter[search] too.
    • Segments#get_subscribers only sent after, so paging always returned page 1. It now takes cursor:. after is still sent unchanged for anyone who passes it.
  2. Subscribers#fetch sends its filter[...] keys in the caller's order. The API only applies start_date, end_date and sort=signup_date when the first filter is form, site, page, import or post, so a fixed order with status first made those params do nothing. Array filter values are now sent comma-separated, as the API documents.
  3. New documented params on existing methods: subscriber list (include, sort, dates, with_fields and the other filters), subscriber create (resubscribe, double_optin, notes), group subscribers (include), segment list (sort), segment update (filter), automation list (sort, with_steps and filters), automation activity (sort, and with_subscribers, sent only when true because the API turns it on for any value).
  4. New methods: Subscribers#activity_log, Groups#import_subscribers, and automation create, update, delete, copy, enable, disable, test, add_subscribers, readd and the three activity actions.
  5. New classes for the automation sub-resources, so Automations stays under the rubocop class length limit: AutomationTriggers, AutomationSteps, AutomationEmails, AutomationTemplates, AutomationReports.
  6. MailerLite::QueryParams holds the query building the new methods share: boolean to 1/0, filter keys and comma-joined arrays, report params, and the URI.
  7. Specs for every new or changed method. They are WebMock stubs that assert the HTTP method, path, query and JSON body against the OpenAPI document, because the existing VCR cassettes need a live account to record. The filter order spec checks the raw URI, since WebMock normalises query order.

No existing method signature changed and nothing was removed. client.rb is untouched.

The e-commerce automation reports (monthly-totals/ecommerce, order-activity, ecommerce-overview-stats) are not in this PR, because the open e-commerce PR #39 adds them.

Endpoint checklist

"Live call" means the method was called once against a local API on a test account, and the effect was read back with a separate request: the rename stored, the subscriber in the group, the test email delivered, page 2 different from page 1, and so on.

Subscribers

Endpoint SDK method How checked
POST /subscribers Subscribers#create (resubscribe, double_optin, notes) existing method, live call
POST /subscribers (notes stored) Subscribers#create notes existing method, live call
GET /subscribers/{subscriber} Subscribers#get spec + live call
PUT /subscribers/{subscriber} Subscribers#update spec + live call
GET /subscribers/{subscriber}/activity-log Subscribers#activity_log spec + live call
GET /subscribers/import/{import} Subscribers#get_single_import existing method, live call
GET /subscribers Subscribers#fetch (filters, sort, include, with_fields, cursor) existing method, live call
POST /subscribers/{subscriber}/forget Subscribers#forget existing method, live call
DELETE /subscribers/{subscriber} Subscribers#delete spec + live call

Groups

Endpoint SDK method How checked
POST /groups Groups#create spec + live call
GET /groups Groups#get spec + live call
PUT /groups/{group} Groups#update spec + live call
POST /subscribers/{subscriber}/groups/{group} Groups#assign_subscriber existing method, live call
DELETE /subscribers/{subscriber}/groups/{group} Groups#unassign_subscriber existing method, live call
POST /groups/{group}/import-subscribers Groups#import_subscribers spec + live call
GET /groups/{group}/subscribers Groups#get_subscribers (query string, include, cursor) existing method, live call
DELETE /groups/{group} Groups#delete spec + live call

Segments

Endpoint SDK method How checked
GET /segments Segments#list (query string, sort) existing method, live call
PUT /segments/{segment} Segments#update (name, filter) existing method, live call
GET /segments/{segment}/subscribers Segments#get_subscribers (cursor, after) existing method, live call
DELETE /segments/{segment} Segments#delete spec + live call

Fields

Endpoint SDK method How checked
POST /fields Fields#create spec + live call
GET /fields Fields#get spec + live call
PUT /fields/{field} Fields#update spec + live call
DELETE /fields/{field} Fields#delete spec + live call

Automations

Endpoint SDK method How checked
segment setup (tinker) n/a existing method, live call
POST /automations Automations#create spec + live call
PUT /automations/{automation} Automations#update spec + live call
POST /automations/{automation}/test Automations#test spec + live call
POST /automations/{automation}/enable Automations#enable spec + live call
POST /automations/{automation}/add-subscribers Automations#add_subscribers spec + live call
GET /automations/{automation}/activity Automations#get_subscriber_activity (filter[search], old filter[:keyword], sort) existing method, live call
POST /automations/{automation}/activity/add-to-group Automations#add_activity_to_group spec + live call
POST /automations/{automation}/activity/skip-delay Automations#skip_activity_delay spec + live call
POST /automations/{automation}/activity/cancel-automation Automations#cancel_activity spec + live call
POST /automations/{automation}/readd Automations#readd spec + live call
POST /automations/{automation}/copy Automations#copy spec + live call
POST /automations/{automation}/disable Automations#disable spec + live call
DELETE /automations/{automation} Automations#delete spec + live call

Automation triggers

Endpoint SDK method How checked
POST /automations/{automation}/triggers AutomationTriggers#create spec + live call
PUT /automations/{automation}/triggers/{trigger} AutomationTriggers#update spec + live call
GET /automations/{automation}/triggers AutomationTriggers#list spec + live call
GET /automations/{automation}/triggers/{trigger} AutomationTriggers#fetch spec + live call
DELETE /automations/{automation}/triggers/{trigger} AutomationTriggers#delete spec + live call

Automation steps

Endpoint SDK method How checked
POST /automations/{automation}/steps AutomationSteps#create (email, delay, email, action) existing method, live call
GET /automations/{automation}/steps/index AutomationSteps#list spec + live call
GET /automations/{automation}/steps/{step} AutomationSteps#fetch spec + live call
PUT /automations/{automation}/steps/{step} AutomationSteps#update spec + live call
POST /automations/{automation}/steps/{step}/copy AutomationSteps#copy spec + live call
POST /automations/{automation}/steps/reorder AutomationSteps#reorder spec + live call
DELETE /automations/{automation}/steps/{step} AutomationSteps#delete spec + live call
PUT /automations/{automation}/steps/{step}/select-ab-test-winner AutomationSteps#select_ab_test_winner spec + live call

Automation emails

Endpoint SDK method How checked
PUT /automations/{automation}/emails/{email}/content AutomationEmails#update_content spec + live call
GET /automations/{automation}/emails/{email}/content AutomationEmails#content spec + live call
GET /automations/{automation}/emails/{email}/report-stats AutomationEmails#report_stats spec + live call
GET /automations/{automation}/emails/{email}/unsubscribe-reasons AutomationEmails#unsubscribe_reasons spec + live call

Automation templates

Endpoint SDK method How checked
GET /automation-templates AutomationTemplates#list spec + live call
POST /automations/select-template/{automationTemplate} AutomationTemplates#select_template spec + live call

Automation reports

Endpoint SDK method How checked
GET /automations/{automation}/steps/run-counts AutomationReports#step_run_counts spec + live call
GET /automations/{automation}/steps/run-counts/{step} AutomationReports#step_run_count spec + live call
GET /automations/{automation}/triggers/run-counts AutomationReports#trigger_run_counts spec + live call
GET /automations/{automation}/triggers/run-counts/{trigger} AutomationReports#trigger_run_count spec + live call
GET /automations/{automation}/ab-steps-stats AutomationReports#ab_steps_stats spec + live call
GET /automations/{automation}/activity/steps/{step}/subscribers AutomationReports#step_subscribers spec + live call
GET /automations/{automation}/activity/triggers/{trigger}/subscribers AutomationReports#trigger_subscribers spec + live call
GET /automations/{automation}/monthly-totals/email AutomationReports#email_monthly_totals spec + live call
GET /automations/{automation}/monthly-totals/ecommerce (none) not on this branch: added by the open e-commerce PR #39
GET /automations/{automation}/order-activity (none) not on this branch: added by the open e-commerce PR #39
GET /automations/{automation}/emails/{email}/ecommerce-overview-stats (none) not on this branch: added by the open e-commerce PR #39
GET /automations/{automation}/ab-steps-stats (with an A/B step) AutomationReports#ab_steps_stats spec + live call
GET /automations/{automation}/ab-steps-stats/{step} AutomationReports#ab_step_stats spec + live call

Risks

Low risk. The changes are additive, apart from the fixes in Changes 1 and 2, which change what the SDK sends:

  • Group subscribers and the segment list now send query params. Before, the API ignored them, so callers got the defaults.
  • An old filter[:keyword] on automation activity now goes out as filter[search]. Before, it always got a 400. A value that is not an email now gets a 422 instead.
  • Subscriber list filters keep the caller's order. A caller who passes status with form now gets the date range and signup_date sort they asked for.

Performance impact

None. Each method makes one request.

Security impact

No security impact. No auth or transport change.

How to QA

No QA needed on the app. This is a library change, and nothing in the MailerLite app changes. Reviewers can run the specs (bundle exec rspec spec/*rspec.rb).

Verified before review: 68 of 71 live calls passed. The other 3 are the e-commerce reports that PR #39 adds. What a local run cannot show:

  • Run counts are always 0, because they read analytics data the local stack does not produce. The calls return 200 with the right step and trigger ids.
  • The report date range does not narrow the local stats. The calls send the documented start_date and end_date.
  • Trigger subscribers returns an empty list, because add-subscribers runs are not trigger runs.

Specs: 99 examples, 0 failures. Rubocop: no new offenses (the 8 it reports are the existing gemspec ones).

How to release

Standard gem release. The CHANGELOG has an Unreleased entry. The open simple-editor PR #40 also adds a block at the top of the CHANGELOG, so whichever merges second has a small conflict there.

Rollback strategy

Primary rollback method: revert

Code changes

  • Safe to revert. SDK code only.

Database migrations

  • None.

Data modifications

  • None.

External dependencies

  • None.

Configuration changes:

  • None.

Screenshots, recordings

N/A, library change.

I used AI to generate parts of this PR

Yes

Docs

The PR adheres to Pull Request guidelines.

See mandatory MailerLite PR rules and flow for more information.

@kavanpancholi kavanpancholi self-assigned this Oct 30, 2026
@kavanpancholi
kavanpancholi marked this pull request as ready for review October 30, 2026 11:41
@mailerlite-kritika

mailerlite-kritika Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Re-runViewConfidence Score: 4/5

[Medium risk] The new spec support file requires 'webmock/rspec' and the account says WebMock is now loaded globally, which blocks real connections for the whole suite, but the Gemfile is not in the changed files and the review did not check that webmock is a declared development dependency or that existing specs still pass. Risk rests on the change's public-interface edits: Groups#get_subscribers and Segments#list move params from a JSON body to the query string, and Subscribers#fetch changes filter …

Findings

Earlier findings (1 dismissed)

Summary

Adds Ruby SDK automation endpoints and fixes misplaced GET params

New AutomationTriggers, AutomationSteps, AutomationEmails, AutomationTemplates and AutomationReports classes, plus new methods on Automations, Groups and Subscribers, cover the missing public API endpoints. A shared MailerLite::QueryParams module, required in lib/mailerlite.rb before the resource classes, builds the query strings. Merging also changes what existing calls send: Groups#get_subscribers and Segments#list now put params in the query string, Subscribers#fetch keeps the caller's filter order, and Automations#get_subscriber_activity sends filter[search] instead of filter[keyword]. The new specs use WebMock, loaded globally in spec/spec_helper.rb, so real network connections are now blocked in the suite.

What's good

  • Query-string building is pulled into one small QueryParams module instead of being repeated in every method.
  • The deprecated filter[:keyword] and after inputs still work, so existing callers are not broken.
  • Specs assert the exact HTTP method, path, query and body per endpoint, and the filter-order spec checks the raw URI that WebMock would otherwise normalise.
Review context · 0/5 commands
  • Commands run: none

No agent named again is on, so every agent that applies ran.
Reviewed in 2 parts, each by an agent of its own.

Reviews (3) · Last reviewed commit: "Cover Array filter values on subscriber..." · claude-sonnet-5-5

Comment thread spec/subscribers_rspec.rb Resolved
@kavanpancholi

Copy link
Copy Markdown
Contributor Author

@mailerlite-kritika review again

@kavanpancholi
kavanpancholi requested a review from dinomh October 30, 2026 11:53
@kavanpancholi
kavanpancholi merged commit 71bf371 into main Nov 3, 2026
3 checks passed
@kavanpancholi
kavanpancholi deleted the feature/engl-663-catch-up-the-ml-sdks-with-the-public-api-subscribers-groups branch November 3, 2026 09:45
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