Skip to content

Full API coverage - #4

Merged
michaeldoehler merged 1 commit into
mainfrom
full-api-coverage
Sep 14, 2026
Merged

michaeldoehler merged 1 commit into
mainfrom
full-api-coverage

Conversation

@michaeldoehler

Copy link
Copy Markdown
Contributor

The SDK covered 6 of the 11 API surfaces. This adds the rest:

Service Methods
campaigns() createDraft, createAndSend, list, listForStream, get, getForStream, update, send, cancel
subscribers() list, add, importAddresses, complaint, remove
layouts() list, create, get, update, delete, uploadLogo
inbound() list, get, retry, bypass
logs() list, tags

Plus emails().sendToStream() and an idempotency-key overload on all four
send methods:

client.emails().send(request, "order-" + orderId);

Two ways to create a campaign

POST /streams/{permalink}/campaigns sets the status to sending and
expands to the subscribers before the response returns; POST /campaigns
names the stream in the body and honours scheduled_at. Hence
createAndSend and createDraft: a single create would be a trap (see
camelmailer/camelmailer#25).

UpdateCampaignRequest carries clearSchedule next to scheduledAt,
because omitting scheduled_at and sending it as null mean different
things: omitting it leaves the schedule standing, only an explicit null
drops the campaign back to draft. The mapper is configured NON_NULL, so
the service builds that body as an ObjectNode and calls putNull, with a
test asserting the null reaches the wire.

StreamRequest could not set a permalink

StreamRequest had only name and streamType. Without a permalink the
API derives one from the name, so a caller that needs to know the permalink
up front had to create the stream and then search the list for it — which
is exactly what the integration test had to do before this. It now takes
permalink and archived.

Verification

87 tests, Spotless and mvn verify clean. Live against a real instance:
the broadcast round trip (stream, subscribers, import, all three campaign
creations, schedule and unschedule, cancel, sendToStream), the
idempotency replay and its 409 conflict, and the layout logo upload.

Releases as 0.2.0.

Adds the five surfaces the SDK was missing: campaigns, subscribers,
layouts, inbound and logs, plus emails().sendToStream().

Campaigns get two create methods rather than one, because the API has
two routes that behave differently: createDraft writes the campaign and
waits, while createAndSend expands it to the stream's subscribers before
the call returns.

UpdateCampaignRequest carries clearSchedule alongside scheduledAt,
because omitting the field and sending an explicit null mean different
things to the API: an omitted field leaves the schedule standing, only a
null clears it. The mapper drops null properties, so the service builds
that body as a node and puts the null in explicitly.

All four send methods gain an idempotency-key overload. The key travels
as a header, because the body is what the server hashes to recognise a
replay.

StreamRequest takes a permalink and an archived flag. Without the
permalink the API derives one from the name, so a caller that has to know
the permalink up front had to create the stream and then search the list
for it.

Verified against a live instance: a replayed key returns the first
message id, a different body under the same key is refused with
InvalidIdempotentRequest, createDraft comes back draft, with a schedule
scheduled, createAndSend comes back sending, and uploadLogo returns a
real URL.
@michaeldoehler
michaeldoehler merged commit bce211a into main Sep 14, 2026
2 checks passed
@michaeldoehler
michaeldoehler deleted the full-api-coverage branch September 14, 2026 09:41
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.

1 participant