<aside> π
Links (Block base class)
Notion Ruby Mapping Public API Reference
</aside>
$\fbox{implemented in UrlCaptionBaseBlock}$
[PARAM] url bookmark URL (String)
[PARAM(optional)] caption defaults to an empty caption
<aside> π
The following objects are used for this argument.
[RETURN] BookmarkBlock
[RAISE] ArgumentError
when neither url nor reconstruction JSON is provided
self.new creates a BookmarkBlock 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 = BookmarkBlock.new "<https://www.google.com/>", caption: "Google"
b.block_json
# => {"type"=>"bookmark", "object"=>"block", "bookmark"=>{"caption"=>[{"type"=>"text", "text"=>{"content"=>"Google", "link"=>nil}, "plain_text"=>"Google", "href"=>nil], "url"=>"<https://www.google.com/>"}}
$\fbox{implemented in Block}$
true returns a verification script without sending the request (Boolean)BookmarkBlock, 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 BookmarkBlock.
block = Block.find "bookmark_block_id"
block.url = "<https://www.apple.com/>"
block.caption.rich_text_objects = "Apple"
block.save
# => #<NotionRubyMapping::BookmarkBlock:...>
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/bookmark_block_id>' ...
# --data '{"bookmark":{"url":"<https://www.apple.com/","caption>":[...]}}'
$\fbox{implemented in UrlCaptionBaseBlock}$
caption returns the RichTextArray used by BookmarkBlock. Modify the returned object to include caption changes in the next Block update. A supplied RichTextArray is normalized to the caption key.
b = BookmarkBlock.new "<https://www.google.com/>", caption: "Google"
b.caption.rich_text_objects = "Updated caption"
b.update_block_json
# => {"bookmark"=>{"caption"=>[{"type"=>"text", "text"=>{"content"=>"Updated caption", "link"=>nil}, "plain_text"=>"Updated caption", "href"=>nil]}}