Skip to content

Add SDK code samples to email campaigns endpoints - #54

Merged
Rabsztok merged 4 commits into
mainfrom
campaigns-sdk-samples
Sep 5, 2026
Merged

Add SDK code samples to email campaigns endpoints#54
Rabsztok merged 4 commits into
mainfrom
campaigns-sdk-samples

Conversation

@Rabsztok

@Rabsztok Rabsztok commented Aug 31, 2026

Copy link
Copy Markdown
Member

Motivation

Every one of the 11 operations in
specs/email-campaigns.openapi.yml carried only a shell sample, while sibling specs
(e.g. createContact in contacts.openapi.yml) carry the full SDK set. Campaigns were
the only spec with no SDK samples at all.

Changes

  • Add javascript, php, python, ruby, csharp and java samples to all 11 email
    campaign operations, in the language order and with the label conventions the sibling
    specs already use. Existing shell samples are untouched.
  • Every sample is written against the campaigns API each SDK actually ships on its
    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:

Operation Node.js PHP Python Ruby .NET Java
getEmailCampaigns yes yes yes yes yes yes
createEmailCampaign yes yes yes yes yes yes
getEmailCampaign yes yes yes yes yes yes
updateEmailCampaign yes yes yes yes yes yes
deleteEmailCampaign yes yes yes yes yes yes
startEmailCampaign yes yes yes yes yes yes
scheduleEmailCampaign yes yes yes yes yes yes
cancelEmailCampaign yes yes yes yes yes yes
terminateEmailCampaign yes yes yes yes yes yes
resetEmailCampaign yes yes yes yes yes yes
getEmailCampaignStats yes yes yes yes yes yes

Entry points used, for reviewer reference:

  • Node.js — client.emailCampaigns.{getList,create,get,update,delete,start,schedule,cancel,terminate,reset,getStats}
  • PHP — (new MailtrapGeneralClient($config))->emailCampaigns($accountId)->…EmailCampaign…()
  • Python — client.email_campaigns_api.email_campaigns.{get_list,create,get_by_id,update,delete,start,schedule,cancel,terminate,reset,get_stats}
  • Ruby — Mailtrap::EmailCampaignsAPI.new(client).{list,get,create,update,delete,start,schedule,cancel,terminate,reset,stats}
  • .NET — client.EmailCampaigns() (collection) and client.EmailCampaign(id) (single)
  • Java — 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: createSuppression and the three
tracking_opt_outs operations in email-sending.openapi.yml also lack ruby samples.

How to test

  • Spectral reports no errors for specs/*.openapi.yml
  • In the rendered GitBook docs, each email campaigns operation offers cURL, Node.js,
    PHP, Python, Ruby, .NET and Java tabs, in that order
  • Spot-check createEmailCampaign and updateEmailCampaign: the sample bodies use the
    fields 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), and scheduleEmailCampaign uses datetime

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>
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 568f6824-5441-48aa-93c6-02303fe3e886


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Rabsztok
Rabsztok marked this pull request as ready for review August 31, 2026 11:25
@Rabsztok
Rabsztok requested review from IgorDobryn and izikaj August 31, 2026 11:26
Comment thread specs/email-campaigns.openapi.yml Outdated
Comment thread specs/email-campaigns.openapi.yml Outdated
Rabsztok and others added 3 commits September 2, 2026 12:29
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>
@Rabsztok
Rabsztok merged commit 086b2eb into main Sep 5, 2026
2 checks passed
@Rabsztok
Rabsztok deleted the campaigns-sdk-samples branch September 5, 2026 10:15
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.

3 participants