Skip to content

Document rejected on block writes and own templates for template_id - #42

Merged
dinomh merged 3 commits into
feature/cmac-1016-add-the-simple-editor-email-endpoints-to-the-ruby-sdkfrom
feature/document-rejected-on-block-writes
Nov 12, 2026
Merged

dinomh merged 3 commits into
feature/cmac-1016-add-the-simple-editor-email-endpoints-to-the-ruby-sdkfrom
feature/document-rejected-on-block-writes

Conversation

@tomasmartty

Copy link
Copy Markdown
Contributor

Why?

The API changed for two features of #40:

  • Insert, update and validate a block can return rejected. The API drops the attributes and the mobile keys that the block type does not declare. The write still succeeds, and rejected has a message and the keys that the API dropped.
  • template_id of Campaigns#create now also accepts a simple editor template that you saved from your own email. Before, it accepted only a template from the shared gallery.

The SDK returns the response body as it is, so rejected already gets to the caller. This PR adds the docs and specs for it, and corrects the template_id and editor docs.

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

Changes

  1. rejected on block writes (lib/mailerlite/emails/emails.rb, README.md)
    • create_block and update_block: the docs say when the response has rejected, and what it contains. The README examples print rejected.keys when it is present.
    • validate_block: the docs say that a valid block can have rejected, and that the response has no rejected when valid is false.
    • move_block does not change, because the API does not return rejected for a move.
    • No code change. The SDK has no typed models, so there is no field to add.
  2. Specs and fixtures: two new specs for create_block and update_block, with the new fixtures email_block_created_rejected.json and email_block_updated_rejected.json.
  3. template_id and editor (lib/mailerlite/campaigns/campaigns.rb, README.md)
    • template_id is a template from the shared gallery, or a template that you saved with Emails#create_template. Without it, the email starts from the default blank template.
    • editor no longer compares the simple editor with the drag-and-drop builder. The docs now say that editor is not available on every plan.
    • These facts do not change: template_id needs editor: "simple", and all emails of a campaign must have the same editor and template_id.
  4. CHANGELOG.md: one entry under "Unreleased" for the rejected docs.

Compatibility

Docs and specs only. No method signature, return value or behavior changes.

Tests

  • TDD: the two new specs failed first with Errno::ENOENT, because the fixtures did not exist. They passed after the fixtures were added. These specs cannot fail because of the SDK code, because the SDK already returns the body as it is. They document the shape and protect it from a future change that filters the body.
  • rspec spec/*rspec.rb (248 examples) passes on Ruby 3.1. RuboCop finds no new offenses.
  • A development instance of the API, through the SDK:
    • create_block with editor_content.attrs.onclick returned 201 with rejected.keys ["editor_content.attrs.onclick"].
    • update_block with editor_content.mobile.onclick returned 200 with rejected.keys ["editor_content.mobile.onclick"]. Clean content returned no rejected.
    • validate_block returned rejected for a valid block, and no rejected for an invalid block.
    • Campaigns#create with editor: "simple" and the template_id from create_template returned 201.

How to test

  1. Run rspec spec/*rspec.rb.
  2. Get an API token for a test account. Create a campaign with editor: MailerLite::Campaigns::EDITOR_SIMPLE, and get the email ID.
  3. Run the README example "Insert a block" with editor_content: { attrs: { onclick: 'x' }, content: [{ type: 'text', text: 'Hi' }] }.
  4. Make sure that the example prints ["editor_content.attrs.onclick"].
  5. Run "Save an email as a template". Create a campaign with editor: MailerLite::Campaigns::EDITOR_SIMPLE and template_id set to the id of the template. Make sure that the response is 201.

How to release

Release this with #40. It needs no separate release.

Rollback

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

🤖 Generated with Claude Code

tomasmartty and others added 3 commits November 11, 2026 16:35
The API drops the attributes and the mobile keys that the block type
does not declare. The write still succeeds, and the response has
rejected with the dropped keys. The SDK returns the body as it is.

These specs check that create_block and update_block return rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Insert, update and validate a block can return rejected. It has a
message and the keys that the API dropped. Validate returns it only
when the block is valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
template_id accepts a simple editor template from the shared gallery,
or a template that you saved from your own email with create_template.

Describe editor without the comparison to the drag-and-drop builder.
Say that editor is not available on every plan.

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

Copy link
Copy Markdown

Re-runViewConfidence Score: 5/5

[Low risk] The change is docs, specs and fixtures only, with no runtime code and no dependency version moved, so the risk rests on the diff alone. The API behaviour it documents (the rejected keys and saved templates as template_id) is backed by the dev-instance runs in the description, not by any source the review read, but a wrong doc line would not change what the SDK sends.

Summary

Documents rejected block keys and own templates for template_id

This is a docs and specs change on top of #40. It adds rejected notes to create_block, update_block and validate_block in the README and YARD comments. It rewrites the template_id and editor docs for Campaigns#create, and adds a CHANGELOG line. Two new specs with fixtures check that the SDK returns the rejected body unchanged. No runtime code changes.

What's good

  • The docs separate when rejected appears from when it does not: a valid block can have it, an invalid one cannot, and move_block never does.
  • The README examples print rejected.keys when present, so the new field is easy to find.
  • The PR says plainly that the new specs guard the response shape and cannot fail from SDK logic.
Review context · 0/5 commands
  • Commands run: none

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

@tomasmartty
tomasmartty requested a review from dinomh November 11, 2026 15:53
@tomasmartty
tomasmartty added this pull request to stack #43 November 12, 2026 10:57
@dinomh
dinomh merged commit 42274b1 into main Nov 12, 2026
3 checks passed
@dinomh
dinomh deleted the feature/document-rejected-on-block-writes branch November 12, 2026 10:59
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