Skip to content

ENGL-663: Catch up the PHP SDK with the public API - #44

Merged
kavanpancholi merged 6 commits into
mainfrom
feature/engl-663-catch-up-the-ml-sdks-with-the-public-api-subscribers-groups
Oct 30, 2026
Merged

kavanpancholi merged 6 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 PHP SDK was behind the public API. It could read automations but not build, change or control them, and segment subscribers could not page. This catches it up with every subscribers, groups, segments, fields and automations endpoint on ENGL-663.

Changes

  1. Segment::getSubscribers() now takes an optional $params array, so cursor, limit and filter[status] can be sent. One-argument calls still work. This was the known bug on the card.
  2. Subscriber: getActivityLog() and findImport().
  3. Group: importSubscribers() (POST /groups/{group}/import-subscribers).
  4. Automation: 40 new methods for automation CRUD, copy, enable, disable, test, add-subscribers, readd, the three activity actions, triggers, steps (including reorder, copy and A/B winner), email content, email stats, templates and the run count, A/B and subscriber reports. deleteStep() sends branch_to_delete as a query param, because the PSR transport drops DELETE bodies.
  5. Tests: one data-provider case per automation endpoint in AutomationTest::test_request, plus SubscriberTest::test_get_activity_log, test_find_import, GroupTest::test_import_subscribers and SegmentTest::test_get_segment_subscribers_with_params. Each asserts the HTTP method, path, query and JSON body against the OpenAPI document. A new tests/Support/AssertsRequests trait holds that assertion, and EcommerceTest now uses it with the same behaviour as before.
  6. README examples for every new method.

No existing method signature changed and nothing was removed. src/MailerLite.php is untouched, since no new endpoint class was needed.

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() existing method, live call
GET /subscribers/{subscriber} subscribers->find() existing method, live call
PUT /subscribers/{subscriber} subscribers->update() existing method, live call
GET /subscribers/{subscriber}/activity-log subscribers->getActivityLog() unit test + live call
GET /subscribers subscribers->get() existing method, live call
GET /subscribers/import/{import} subscribers->findImport() unit test + live call
POST /subscribers/{subscriber}/forget subscribers->forget() existing method, live call
DELETE /subscribers/{subscriber} subscribers->delete() existing method, live call

Groups

Endpoint SDK method How checked
POST /groups groups->create() existing method, live call
GET /groups groups->get() existing method, live call
PUT /groups/{group} groups->update() existing method, live call
POST /subscribers/{subscriber}/groups/{group} groups->assignSubscriber() existing method, live call
POST /groups/{group}/import-subscribers groups->importSubscribers() unit test + live call
GET /groups/{group}/subscribers groups->getSubscribers() existing method, live call
DELETE /subscribers/{subscriber}/groups/{group} groups->unAssignSubscriber() existing method, live call
DELETE /groups/{group} groups->delete() existing method, live call

Segments

Endpoint SDK method How checked
GET /segments segments->get() existing method, live call
PUT /segments/{segment} segments->update() existing method, live call
GET /segments/{segment}/subscribers segments->getSubscribers() unit test + live call (cursor page 2 differs from page 1)
DELETE /segments/{segment} segments->delete() existing method, live call

Fields

Endpoint SDK method How checked
POST /fields fields->create() existing method, live call
GET /fields fields->get() existing method, live call
PUT /fields/{field} fields->update() existing method, live call
DELETE /fields/{field} fields->delete() existing method, live call

Automations

Endpoint SDK method How checked
POST /automations automations->create() unit test + live call
PUT /automations/{automation} automations->update() unit test + live call
POST /automations/{automation}/test automations->test() unit test + live call
POST /automations/{automation}/enable automations->enable() unit test + live call
POST /automations/{automation}/add-subscribers automations->addSubscribers() unit test + live call
GET /automations/{automation}/activity automations->activity() existing method, live call
POST /automations/{automation}/activity/add-to-group automations->addActivityToGroup() unit test + live call
POST /automations/{automation}/activity/skip-delay automations->skipActivityDelay() unit test + live call
POST /automations/{automation}/activity/cancel-automation automations->cancelActivity() unit test + live call
POST /automations/{automation}/readd automations->readd() unit test + live call
POST /automations/{automation}/copy automations->copy() unit test + live call
POST /automations/{automation}/disable automations->disable() unit test + live call
DELETE /automations/{automation} automations->delete() unit test + live call

Automation triggers

Endpoint SDK method How checked
POST /automations/{automation}/triggers automations->createTrigger() unit test + live call
GET /automations/{automation}/triggers automations->getTriggers() unit test + live call
GET /automations/{automation}/triggers/{trigger} automations->findTrigger() unit test + live call
PUT /automations/{automation}/triggers/{trigger} automations->updateTrigger() unit test + live call
DELETE /automations/{automation}/triggers/{trigger} automations->deleteTrigger() unit test + live call

Automation steps

Endpoint SDK method How checked
POST /automations/{automation}/steps automations->createStep() unit test + live call
GET /automations/{automation}/steps/index automations->getSteps() unit test + live call
GET /automations/{automation}/steps/{step} automations->findStep() unit test + live call
PUT /automations/{automation}/steps/{step} automations->updateStep() unit test + live call
POST /automations/{automation}/steps/{step}/copy automations->copyStep() unit test + live call
POST /automations/{automation}/steps/reorder automations->reorderSteps() unit test + live call
DELETE /automations/{automation}/steps/{step} automations->deleteStep() unit test + live call
PUT /automations/{automation}/steps/{step}/select-ab-test-winner automations->selectAbTestWinner() unit test + live call
DELETE /automations/{automation}/steps/{step} with branch_to_delete automations->deleteStep() unit test + live call

Automation emails

Endpoint SDK method How checked
PUT /automations/{automation}/emails/{email}/content automations->updateEmailContent() unit test + live call
GET /automations/{automation}/emails/{email}/content automations->getEmailContent() unit test + live call
GET /automations/{automation}/emails/{email}/report-stats automations->getEmailReportStats() unit test + live call
GET /automations/{automation}/emails/{email}/unsubscribe-reasons automations->getEmailUnsubscribeReasons() unit test + live call

Automation templates

Endpoint SDK method How checked
GET /automation-templates automations->getTemplates() unit test + live call
POST /automations/select-template/{automationTemplate} automations->selectTemplate() unit test + live call

Automation reports

Endpoint SDK method How checked
GET /automations/{automation}/steps/run-counts automations->getStepRunCounts() unit test + live call
GET /automations/{automation}/steps/run-counts/{step} automations->getStepRunCount() unit test + live call
GET /automations/{automation}/triggers/run-counts automations->getTriggerRunCounts() unit test + live call
GET /automations/{automation}/triggers/run-counts/{trigger} automations->getTriggerRunCount() unit test + live call
GET /automations/{automation}/ab-steps-stats automations->getAbStepsStats() unit test + live call
GET /automations/{automation}/activity/steps/{step}/subscribers automations->getStepSubscribers() unit test + live call
GET /automations/{automation}/activity/triggers/{trigger}/subscribers automations->getTriggerSubscribers() unit test + live call
GET /automations/{automation}/monthly-totals/email automations->getEmailStats() unit test + live call
GET /automations/{automation}/monthly-totals/ecommerce automations->getEcommerceStats() existing method, live call
GET /automations/{automation}/order-activity automations->getEcommerceOrders() existing method, live call
GET /automations/{automation}/emails/{email}/ecommerce-overview-stats automations->getEmailEcommerceStats() existing method, live call
GET /automations/{automation}/ab-steps-stats/{step} automations->getAbStepStats() unit test + live call

Risks

Low risk. The change is additive: new methods, and one new optional parameter. The one behaviour change is that Segment::getSubscribers() now forwards query params. A caller who passed nothing before sends the same request as before.

Anyone who extends these endpoint classes and already declares a method with one of the new names (for example Automation::copy() or test()) gets a signature clash on upgrade. This is worth a note in the release.

Performance impact

None. Each method builds one URI and 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 composer test.

Verified before review: 69 of 69 live calls passed. What a local run cannot show:

  • Run counts and report stats are always 0, because they read analytics data the local stack does not produce. The calls return 200 with the right ids.
  • Trigger subscribers returns an empty list, because add-subscribers runs are not trigger runs.
  • The e-commerce reports return empty data, because the test account has no shop.

How to release

Standard release. The repo keeps no hand-written CHANGELOG, so there is no entry.

Rollback strategy

Primary rollback method: revert

Code changes

  • Safe to revert. Additive SDK methods 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

Copy link
Copy Markdown

Re-runViewConfidence Score: 4/5

[Medium risk] The review's account read no source beyond the diff and ran only grep, yet it asserts that HttpLayerPsrBridge::delete ignores the body, which is the reason deleteStep() sends branch_to_delete in the query string; that transport behaviour is unverified. Otherwise the change is additive: about 40 public methods plus one optional parameter on Segment::getSubscribers, and a revert undoes it, so the risk is medium.

Summary

Adds missing automation, import, activity-log and segment-paging endpoints to the PHP SDK

The change adds about 40 Automation methods, Subscriber::getActivityLog and findImport, and Group::importSubscribers. It also gives Segment::getSubscribers an optional $params array that is forwarded as the query string. deleteStep puts branch_to_delete in the query string, which suits HttpLayerPsrBridge::delete because that method ignores the body. Request-shape tests cover each new method through a shared AssertsRequests trait. EcommerceTest now uses the same trait.

What's good

  • The new tests assert HTTP method, path, query and JSON body for every added endpoint through one shared trait.
  • Segment::getSubscribers keeps its one-argument call working by defaulting $params to [].
  • deleteStep sends branch_to_delete as a query param, which works with the PSR bridge that drops DELETE bodies.
Review context · 1/5 commands
  • Commands run: grep

Reviews (1) · Last reviewed commit: "Document the new endpoints in the README" · claude-sonnet-5-5

@kavanpancholi
kavanpancholi requested a review from nxu October 30, 2026 11:52
@kavanpancholi
kavanpancholi merged commit 9692c46 into main Oct 30, 2026
9 checks passed
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