MT-22401: Add Email Campaigns API - #148
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a typed Email Campaigns API with CRUD, lifecycle actions, scheduling, termination, reset, statistics, MailtrapClient exposure, Axios-mock tests, and an end-to-end example documented in the README. ChangesEmail campaigns integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant MailtrapClient
participant EmailCampaignsBaseAPI
participant EmailCampaignsApi
participant MailtrapAPI
Client->>MailtrapClient: access emailCampaigns
MailtrapClient->>EmailCampaignsBaseAPI: construct accessor with shared Axios instance
EmailCampaignsBaseAPI->>EmailCampaignsApi: bind campaign methods
EmailCampaignsApi->>MailtrapAPI: send CRUD or lifecycle request
MailtrapAPI-->>EmailCampaignsApi: return campaign, stats, or error
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Applied the same fix CodeRabbit raised on the Python PR: |
Decisions:
- Request bodies are flat (no email_campaign wrapper) per the current OpenAPI contract
- Single-object and stats responses keep the {data} envelope (Webhooks convention; the axios interceptor only unwraps the HTTP body)
- delete() returns void — the API responds 204 No Content
- Added the five lifecycle endpoints (start/schedule/cancel/terminate/reset) with schedule taking {datetime}
- current_state typed as the 10-value enum; domain_id is the numeric sending-domain ID from the Sending Domains endpoints; template_attributes shared between create and update with no template id
ac3adfd to
47c3416
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/email-campaigns/everything.ts`:
- Around line 62-66: Replace the hard-coded past datetime in the schedule call
with an execution-relative future time, and update the statistics request to
omit the fixed May 2026 filter or generate a window covering the campaign’s
actual send time. Preserve the subsequent cancellation, sending, termination,
statistics, and deletion flow in the example.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a6faa18b-135f-4a61-a765-a94f584cc216
📒 Files selected for processing (8)
README.mdexamples/email-campaigns/everything.tssrc/__tests__/lib/api/EmailCampaigns.test.tssrc/__tests__/lib/api/resources/EmailCampaigns.test.tssrc/lib/MailtrapClient.tssrc/lib/api/EmailCampaigns.tssrc/lib/api/resources/EmailCampaigns.tssrc/types/api/email-campaigns.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- README.md
- src/tests/lib/api/EmailCampaigns.test.ts
- src/lib/MailtrapClient.ts
- src/lib/api/EmailCampaigns.ts
- src/tests/lib/api/resources/EmailCampaigns.test.ts
- src/types/api/email-campaigns.ts
- src/lib/api/resources/EmailCampaigns.ts
Decisions: - The endpoint is token-scoped and resolves the account server-side, so requiring accountId made a valid token-only client unusable (matches the inbound getter precedent and the fix applied to the Python SDK) - Example no longer configures accountId
47c3416 to
d5a81a9
Compare
Motivation
MT-22401
Port the Email Campaigns public API (MT-21113) to the Node.js SDK. The MCP server's campaigns tools depend on this landing and being released to npm.
Changes
client.emailCampaignscovering the full contract:getList(page-token pagination + search),get,create,update,delete(204 →void), the five lifecycle actions (start,schedule,cancel,terminate,reset), andgetStatswith an optional date range{data}response envelopes (Webhooks convention), numericdomain_id(matching the Sending Domains endpoints ids),rapid/gradualdelivery modes, 10-valueCampaignState, audience id arrays,TemplateAttributes(subjectrequired on create) withbody_html/body_text/merge_tags, per-recipient state-metadata errorsexamples/email-campaigns/everything.ts+ README bulletHow to test
examples/email-campaigns/everything.tswith a real API token and a verified sending domain — create a draft, update design/audience, schedule + cancel, fetch stats, deletecancelon a draft) surfaces the API error messageSummary by CodeRabbit
New Features
Documentation
Tests