Add SDK code samples to email campaigns endpoints - #54
Merged
Conversation
All 11 email campaign operations carried only a shell sample. Add javascript, php, python, ruby, csharp and java samples to each, matching the language order and label conventions of the sibling specs. Every sample is written against the campaigns API that each SDK actually ships on origin/main, so all six languages cover all 11 operations. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 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 |
Rabsztok
marked this pull request as ready for review
August 31, 2026 11:25
izikaj
approved these changes
Sep 1, 2026
6 tasks
IgorDobryn
approved these changes
Sep 2, 2026
The schedule samples pinned 2026-06-01, which is already in the past, so copy-pasting them returned 422. Each SDK sample now derives a time one day ahead the way that SDK's own campaigns example does, which also keeps them inside the documented "no more than 1 month ahead" window that any literal would eventually fall outside of. The cURL sample and the two schema examples cannot compute a value, so their literals are moved forward. Also drop the ResponseHelper import from the PHP delete sample: that sample prints the status code and never uses the helper. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The cURL sample was the last schedule example still pinning a literal, so it would rot the same way the SDK samples did. Derive it with `date` instead, preferring the GNU spelling and falling back to the BSD one so the snippet runs on Linux and macOS alike. The `-d` payload has to switch to double quotes for the variable to expand. Restore the original `scheduled_at` example: unlike the request-side `datetime`, that field is a response value, so a past date is what the API would actually return, and 2026-06-01 keeps the example campaign's timeline coherent with the `created_at`/`updated_at` values below it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
main added Go samples to the email campaigns endpoints (PR #55) while this branch was adding the Node.js, PHP, Python, Ruby, .NET and Java samples, so every one of the 11 x-codeSamples lists in specs/email-campaigns.openapi.yml conflicted as an append-vs-append. Resolved by keeping both sides in every list. Concatenating this branch's languages before main's Go sample happens to land on the priority order CLAUDE.md documents: cURL, Node.js, PHP, Python, Ruby, .NET, Java, Go. The one place the two sides genuinely overlapped is the schedule endpoint's cURL sample: main still carried the hardcoded "2026-06-01T09:00:00.000Z" payload that this branch had already replaced with a computed $DATETIME (dafe709, 294867a) precisely because the literal had gone stale and returned 422. This branch's version supersedes it, so main's line is dropped rather than duplicated. Same reasoning for the Schedule schema example, which auto-merged to this branch's 2026-10-01 literal. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Every one of the 11 operations in
specs/email-campaigns.openapi.ymlcarried only ashellsample, while sibling specs(e.g.
createContactincontacts.openapi.yml) carry the full SDK set. Campaigns werethe only spec with no SDK samples at all.
Changes
javascript,php,python,ruby,csharpandjavasamples to all 11 emailcampaign operations, in the language order and with the
labelconventions the siblingspecs already use. Existing
shellsamples are untouched.origin/main— verified method by method, not inferred from the spec.Coverage is complete: 6 languages x 11 operations, no gaps. All six SDKs already ship
full email-campaigns support, so nothing had to be skipped:
getEmailCampaignscreateEmailCampaigngetEmailCampaignupdateEmailCampaigndeleteEmailCampaignstartEmailCampaignscheduleEmailCampaigncancelEmailCampaignterminateEmailCampaignresetEmailCampaigngetEmailCampaignStatsEntry points used, for reviewer reference:
client.emailCampaigns.{getList,create,get,update,delete,start,schedule,cancel,terminate,reset,getStats}(new MailtrapGeneralClient($config))->emailCampaigns($accountId)->…EmailCampaign…()client.email_campaigns_api.email_campaigns.{get_list,create,get_by_id,update,delete,start,schedule,cancel,terminate,reset,get_stats}Mailtrap::EmailCampaignsAPI.new(client).{list,get,create,update,delete,start,schedule,cancel,terminate,reset,stats}client.EmailCampaigns()(collection) andclient.EmailCampaign(id)(single)client.emailCampaignsApi().emailCampaigns().…EmailCampaign…()The campaigns endpoints are token-scoped, so Node.js, Python, Ruby, .NET and Java need no
account id; PHP's resource still takes one for consistency with the other General API
resources, and the sample passes it.
Diff is purely additive (1038 insertions, 0 deletions) — no base-URL, description, or
operation-ordering changes.
Out of scope, deliberately untouched:
createSuppressionand the threetracking_opt_outsoperations inemail-sending.openapi.ymlalso lackrubysamples.How to test
specs/*.openapi.ymlPHP, Python, Ruby, .NET and Java tabs, in that order
createEmailCampaignandupdateEmailCampaign: the sample bodies use thefields the spec defines (
name,domain_id,from_display_name,from_local_part,reply_to,template_attributes,delivery_mode,delivery_options,contact_list_ids,contact_segment_ids), andscheduleEmailCampaignusesdatetime