Skip to content

Return the rejected attributes of block writes - #25

Merged
johnkelesidis merged 2 commits into
feature/cmac-1017-add-the-simple-editor-email-endpoints-to-the-java-sdkfrom
feature/return-rejected-on-block-writes
Nov 12, 2026
Merged

johnkelesidis merged 2 commits into
feature/cmac-1017-add-the-simple-editor-email-endpoints-to-the-java-sdkfrom
feature/return-rejected-on-block-writes

Conversation

@tomasmartty

Copy link
Copy Markdown
Contributor

Why?

The API changed after #23 was written:

  • A block insert, a block update and a block validation can now return rejected. The API removes the attributes and the mobile keys that the block type does not declare, and the write is still a success. SingleEmailBlock had no field for it, so Gson dropped it, and the caller could not see that the API removed values.
  • template_id on a campaign create now also accepts a simple editor template that the account saved from its own email. The SDK docs said "only a template from the shared gallery".

This PR is stacked on #23. Merge it after #23, or retarget it to main when #23 is merged.

Changes

  1. rejected on block writes (first commit)
    • SingleEmailBlock has a new nullable field: rejected, of the existing type EmailRejected (message and keys). Only createBlock and updateBlock fill it. getBlock and moveBlock leave it null.
    • The Javadoc of createBlock and updateBlock and the README sections "Insert a block" and "Update a block" describe the field. The two README examples print the keys when rejected is not null.
    • The Javadoc of EmailValidation.rejected no longer says that only the settings validation has it. The API sends it for a block validation too, only when valid is true. The Javadoc of validateBlock and the README section "Validate a block" say this.
    • The Javadoc of EmailRejected now covers the block keys too, for example editor_content.attrs.onclick.
  2. template_id docs (second commit, docs only)
    • The Javadoc of EmailBase.templateId and the README section "Create a campaign with the simple editor" now say: a template from the shared gallery, or a template that you saved from your own email with createTemplate. It still needs editor set to simple, and it must be the same on every email.
    • The Javadoc of createTemplate and the README section "Save an email as a template" say that the ID of the new template works as templateId.

Compatibility

All changes add to the public API. No public signature changes. Code that reads SingleEmailBlock continues to work. rejected is null when the API sends no rejected.

Tests

  • New tests with response fixtures:
    • createBlock and updateBlock with rejected: the test checks message and keys. The update fixture has an attrs key and a mobile key.
    • createBlock, updateBlock, getBlock and moveBlock without rejected: rejected is null.
    • validateBlock with rejected on a valid block.
  • The README examples "Insert a block" and "Update a block" run against responses with rejected.
  • mvn test passes on JDK 11 and on JDK 21 (180 tests, 0 failures, 0 errors). mvn javadoc:javadoc on JDK 11 gives no warnings.
  • The block writes also ran against a development instance of the API, through the SDK. An insert and an update of a paragraph block with editor_content.attrs.onclick returned rejected.keys with editor_content.attrs.onclick, and SingleEmailBlock.rejected had the same keys. A move returned no rejected, and the field was null. A campaign create with the ID from createTemplate as templateId returned 201.
  • The second commit changes only docs, so it has no test.

How to test

  1. Run mvn test. pom.xml sets testFailureIgnore, so read the Tests run summary, not the exit code.
  2. Get an API token for a test account. Create a campaign with the simple editor, and get the email ID.
  3. Run the README example "Insert a block" with "onclick", "x" in attrs. Make sure that response.rejected.keys has editor_content.attrs.onclick.
  4. Run the README example "Move a block" on that block. Make sure that response.rejected is null.

How to release

Release this together with #23. No separate release is necessary.

Rollback

No data or configuration changes. To roll back, revert the merge commit.

🤖 Generated with Claude Code

tomasmartty and others added 2 commits November 11, 2026 16:33
The API now removes the attributes and the mobile keys that a block type
does not declare, and adds "rejected" to the response of a block insert,
a block update and a block validation. SingleEmailBlock had no field for
it, so Gson dropped it. SingleEmailBlock now has a nullable rejected field
of the existing EmailRejected type. The Javadoc of EmailValidation no
longer says that only the settings validation has rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The API now accepts as template_id a simple editor template from the
shared gallery or a template that the account saved from its own email.
The Javadoc of EmailBase.templateId and the README said "only a template
from the shared gallery". The Javadoc of createTemplate and the README
now say that the ID of the new template works as template_id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mailerlite-kritika

Copy link
Copy Markdown

Re-runViewConfidence Score: 5/5

[Low risk] The risk rests on an additive, nullable rejected field on SingleEmailBlock plus Javadoc, README and test changes, with no existing signature altered and no dependency version moved. The diff is shown in full and the field is read only when the API sends it, so the change is low risk.

Summary

Adds rejected attributes to block write responses and updates template docs

SingleEmailBlock gains a nullable rejected field of the existing EmailRejected type. Gson fills it for createBlock and updateBlock whenever the API sends it, and it stays null for getBlock and moveBlock. The rest is Javadoc and README updates, covering the block-validation rejected and templateId accepting a template saved with createTemplate. The new tests use response fixtures and cover both the rejected and the null cases. The README insert and update examples now run against the rejected fixtures.

What's good

  • Tests assert both the populated rejected and the null case on create, update, get and move.
  • The README examples are updated and exercised by ReadmeExamplesTest against the new fixtures.
Review context · 0/5 commands · 1 overlapping pull request
  • Commands run: none
  • Also open:
    • #22 changes README.md

Reviews (1) · Last reviewed commit: "docs: say that template_id also accepts..." · claude-sonnet-5-5

@johnkelesidis
johnkelesidis merged commit 4fcc9e5 into feature/cmac-1017-add-the-simple-editor-email-endpoints-to-the-java-sdk Nov 12, 2026
1 check passed
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.

2 participants