<aside> πŸ‘‰

Links (Block base class)

Page

AudioBlock

Block

CalloutBlock

DividerBlock

Heading1Block

ImageBlock

ParagraphBlock

TableOfContentsBlock

ToggleHeading2Block

Database

BookmarkBlock

CodeBlock

EmbedBlock

Heading2Block

LinkPreviewBlock

PdfBlock

ToDoBlock

ToggleHeading3Block

DataSource πŸ†•

BreadcrumbBlock

ColumnBlock

EquationBlock

Heading3Block

LinkToPageBlock

QuoteBlock

ToggleBlock

ToggleHeading4Block

List

BulletedListItemBlock

ColumnListBlock

FileBlock

Heading4Block

NumberedListItemBlock

SyncedBlock

ToggleHeading1Block

VideoBlock

Notion Ruby Mapping Public API Reference

</aside>

1. Class methods

self.new(url, caption: []) β†’ EmbedBlock

$\fbox{implemented in UrlCaptionBaseBlock}$

self.new creates an EmbedBlock using url and an optional caption. An empty string is accepted as url; nil is not accepted for normal construction. When caption is omitted, the generated payload contains an empty caption array.

b = EmbedBlock.new "<https://example.com/embed>", caption: "Sample embed"
b.block_json
# => {"type"=>"embed", "object"=>"block", "embed"=>{"caption"=>[{"type"=>"text", "text"=>{"content"=>"Sample embed", "link"=>nil}, "plain_text"=>"Sample embed", "href"=>nil], "url"=>"<https://example.com/embed>"}}

2. Instance methods

caption β†’ RichTextArray

$\fbox{implemented in UrlCaptionBaseBlock}$

caption returns the RichTextArray used by EmbedBlock. Modify the returned object to include caption changes in the next Block update. A supplied RichTextArray is normalized to the caption key.

b = EmbedBlock.new "<https://example.com/embed>", caption: "Sample embed"
b.caption.rich_text_objects = "Updated caption"
b.update_block_json
# => {"embed"=>{"caption"=>[{"type"=>"text", "text"=>{"content"=>"Updated caption", "link"=>nil}, "plain_text"=>"Updated caption", "href"=>nil]}}

save(dry_run: false)

$\fbox{implemented in Block}$

save sends only the changed URL and caption fields through the Update a block API. The response is decoded into an updated EmbedBlock.

block = Block.find "embed_block_id"
block.url = "<https://example.com/new-embed>"
block.caption.rich_text_objects = "Updated embed"
block.save
# => #<NotionRubyMapping::EmbedBlock:...>

Use dry_run: true to inspect the request without sending it.

block.save dry_run: true
# => curl -X PATCH '<https://api.notion.com/v1/blocks/embed_block_id>' ...
#    --data '{"embed":{"url":"<https://example.com/new-embed","caption>":[...]}}'

url β†’ String