MT-22401: Add Email Campaigns API - #119
Conversation
Decisions:
- Request bodies are flat (no {email_campaign: ...} wrapper), matching the controller's top-level params; create and update accept the same writable set
- Single-object and stats responses unwrap the {data: ...} envelope (WebhooksAPI pattern); list returns {data, pagination} via EmailCampaignsListResponse
- delete uses base_delete and returns nil (API responds 204 No Content)
- Five lifecycle endpoints (start/schedule/cancel/terminate/reset) share a private perform_action helper; schedule takes an ISO 8601 datetime
- list(name:) maps to the search query param to filter by name; API is token-scoped, so the constructor takes only a client (AccountsAPI precedent)
📝 WalkthroughWalkthroughAdds typed email campaign entities and a ChangesEmail Campaigns API
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/mailtrap/email_campaigns_api.rb (1)
104-110: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFix YARD
@returntag format fordelete.
#@returnnil(Line 106) should be#@return[nil]to match the@return [Type] descriptionconvention used by every other method in this file, so YARD parses the return type correctly.📝 Proposed fix
# Deletes an email campaign. The campaign must not be in a sending state. # `@param` email_campaign_id [Integer] The email campaign ID - # `@return` nil + # `@return` [nil] # @!macro api_errors def delete(email_campaign_id)🤖 Prompt for 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. In `@lib/mailtrap/email_campaigns_api.rb` around lines 104 - 110, Update the YARD documentation for the delete method so its `@return` annotation uses the bracketed type format [nil], matching the convention used throughout the file; leave the delete implementation unchanged.
🤖 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.
Nitpick comments:
In `@lib/mailtrap/email_campaigns_api.rb`:
- Around line 104-110: Update the YARD documentation for the delete method so
its `@return` annotation uses the bracketed type format [nil], matching the
convention used throughout the file; leave the delete implementation unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 618f5e87-eb29-4288-a78d-8517b08aaaf8
📒 Files selected for processing (7)
README.mdexamples/email_campaigns_api.rblib/mailtrap.rblib/mailtrap/email_campaign.rblib/mailtrap/email_campaigns_api.rbspec/mailtrap/email_campaign_spec.rbspec/mailtrap/email_campaigns_api_spec.rb
Motivation
https://railsware.atlassian.net/browse/MT-22401
Port the Email Campaigns public API (MT-21113) to the Ruby SDK.
Changes
Mailtrap::EmailCampaignsAPIcovering the full contract: list (page-token pagination + name filter), get, create, update, delete, the five lifecycle actions (start,schedule,cancel,terminate,reset), andstatswith an optional date rangeMailtrap::EmailCampaign/EmailCampaignStats/EmailCampaignsListResponseDTOs matching the OpenAPI schema (audience ids, template withbody_html/body_text/merge_tags, 10-state lifecycle)dataenvelope, per the published spec;deletereturnsnilon 204examples/email_campaigns_api.rb+ README "Email marketing" entryHow to test
examples/email_campaigns_api.rbwith a real API token and a verified sending domain — create a draft campaign, update its design, schedule + cancel it, fetch stats, delete itcurrent_state, template fields)Summary by CodeRabbit
New Features
Tests