Repository navigation
Full API coverage - #4
Merged
Merged
Conversation
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.
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.
The SDK covered 6 of the 11 API surfaces. This adds the rest:
campaigns()createDraft,createAndSend,list,listForStream,get,getForStream,update,send,cancelsubscribers()list,add,importAddresses,complaint,removelayouts()list,create,get,update,delete,uploadLogoinbound()list,get,retry,bypasslogs()list,tagsPlus
emails().sendToStream()and an idempotency-key overload on all foursend methods:
Two ways to create a campaign
POST /streams/{permalink}/campaignssets the status tosendingandexpands to the subscribers before the response returns;
POST /campaignsnames the stream in the body and honours
scheduled_at. HencecreateAndSendandcreateDraft: a singlecreatewould be a trap (seecamelmailer/camelmailer#25).
UpdateCampaignRequestcarriesclearSchedulenext toscheduledAt,because omitting
scheduled_atand sending it asnullmean differentthings: omitting it leaves the schedule standing, only an explicit null
drops the campaign back to
draft. The mapper is configuredNON_NULL, sothe service builds that body as an
ObjectNodeand callsputNull, with atest asserting the null reaches the wire.
StreamRequest could not set a permalink
StreamRequesthad onlynameandstreamType. Without a permalink theAPI 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
permalinkandarchived.Verification
87 tests, Spotless and
mvn verifyclean. Live against a real instance:the broadcast round trip (stream, subscribers, import, all three campaign
creations, schedule and unschedule, cancel,
sendToStream), theidempotency replay and its 409 conflict, and the layout logo upload.
Releases as 0.2.0.