<aside> π
Links (Block base class)
Notion Ruby Mapping Public API Reference
</aside>
$\fbox{implemented in UrlCaptionBaseBlock}$
[PARAM] url embed URL (String)
[PARAM(optional)] caption defaults to an empty caption
<aside> π
The following objects are used for this argument.
[RETURN] EmbedBlock
[RAISE] ArgumentError
when neither url nor reconstruction JSON is provided
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>"}}
$\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]}}
$\fbox{implemented in Block}$
true returns a verification script without sending the request (Boolean)EmbedBlock, or a verification script when dry_run: truesave 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>":[...]}}'