Links (Block base class)
PageBookmarkBlockCodeBlockEmbedBlockHeading2BlockLinkToPageBlockQuoteBlockToDoBlockToggleHeading3Block
DatabaseBreadcrumbBlockColumnBlockEquationBlockHeading3BlockNumberedListItemBlockSyncedBlockToggleBlockVideoBlock
↑ Table of Contents
1. Singleton methodsself.find(id, dry_run: false) → , String2. Instance methodsappend_block_children(*blocks, dry_run: false) → Array<Block>, Stringcolumn_list(array_of_sub_blocks) → destroy → , Stringdivider → embed(url, caption: []) → equation(expression) → file(url, caption: []) → heading_1(text_info, color: “default”) → heading_2(text_info, color: “default”) → heading_3(text_info, color: “default”) → image(url, caption: []) → link_to_page(page_id: nil, database_id: nil) → numbered_list_item(text_info, sub_blocks: nil, color: “default”) → paragraph(text_info, sub_blocks: nil, color: “default”) → pdf(url) → quote(text_info, color: “default”) → synced_block(sub_blocks: nil, block_id: nil) → table(table_width:, table_rows:, has_column_header: false, has_row_header: false) → table_of_contents(color: “default”) → template(text_info, sub_blocks: nil) → to_do(text_info, checked: false, color: “default”) → toggle(text_info, sub_blocks: nil, color: “default”) → toggle_heading_1(text_info, sub_blocks: nil, color: “default”) → toggle_heading_2(text_info, sub_blocks: nil, color: “default”) → toggle_heading_3(text_info, sub_blocks: nil, color: “default”) → save(dry_run: false)video(url) →
1. Singleton methods
self.find(id, dry_run: false) → Block, String
- [PARAM] id block_id (String)
- [PARAM] dry_run: true if you want to create a verification script
- [EXCEPTION] StandardError: throw StandardError when the page is not found.
Block.find(id)
creates a Block object with retrieving block API
. The created object has block information generated from the JSON response.block = Block.find "0250fb6d600142eca4c74efb8794fc6b" # Notion API call # => #<NotionRubyMapping::Block:...> # retrieved Block object
Block.find(id, dry_run: true)
creates a shell script using Retrieve a block API for verification.block = Block.find "0250fb6d600142eca4c74efb8794fc6b", dry_run: true # => # #!/bin/sh # curl 'https://api.notion.com/v1/blocks/0250fb6d600142eca4c74efb8794fc6b' \ # -H 'Notion-Version: 2022-02-22' \ # -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \ # -H 'Content-Type: application/json'
2. Instance methods
append_block_children(*blocks, dry_run: false) → Array<Block>, String
- [PARAM] blocks array of blocks
- [PARAM(optional)] dry_run: true if you want to create a verification script
append_block_children
method of an existing block appends some block objects. Some blocks allow child blocks to be set up at the same time. However, due to API limitations, grandchild blocks cannot be created at once. There are many types of blocks, so check the page( Append block children sample) to see how to create blocks.parent_block = Block.find "065babbba0854c188e964feb56291be2" parent_block.append_block_children CodeBlock.new("% ls -l", caption: "List files") # => # #<NotionRubyMapping::Block:0x0000000104e7d150
append_block_children(blocks, dry_run: true)
creates a shell script using Append block children API for verification. parent_block.append_block_children CodeBlock.new("% ls -l", caption: "List files"), dry_run: true # => "#!/bin/sh\ncurl -X PATCH 'https://api.notion.com/v1/blocks/065babbba0854c188e964feb56291be2/children' \\\n -H 'Notion-Version: 2022-02-22' \\\n -H 'Authorization: Bearer '\"$NOTION_API_KEY\"'' \\\n -H 'Content-Type: application/json' \\\n --data '{\"children\":[{\"type\":\"code\",\"object\":\"block\",\"code\":{\"rich_text\":[{\"type\":\"text\",\"text\":{\"content\":\"% ls -l\",\"link\":null},\"plain_text\":\"% ls -l\",\"href\":null}],\"caption\":[{\"type\":\"text\",\"text\":{\"content\":\"List files\",\"link\":null},\"plain_text\":\"List files\",\"href\":null}],\"language\":\"shell\"}}]}'"
column_list(array_of_sub_blocks) → Block
- [PARAM] array_of_sub_blocks
- [Block1, Block2, ...] ... The first column includes Block1, and the second column includes Block2, ....
- [[Block1a, Block1b], [Block2a, Block2b], ...] ... The first column includes Block1a and Block1b, and the second column includes Block2a and Block2b, ...
- This block can only have children column blocks.
column_list
sets column_list parameters to a plain block object. When creating a column list block via Append block children, the column_list must have at least 2 columns, and those columns must have at least one child each.b = Block.new.column_list [ Block.new.callout("Emoji callout", emoji: "✅"), Block.new.callout("Url callout", file_url: "https://img.icons8.com/ios-filled/250/000000/mac-os.png"), ]; b.block_json # => {"type"=>"column_list", "object"=>"block", "column_list"=>{"children"=>[{"type"=>"column", "object"=>"block", "column"=>{"children"=>[{"type"=>"callout", "object"=>"block", "callout"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Emoji callout", "link"=>nil}, "plain_text"=>"Emoji callout", "href"=>nil}], "color"=>"default", "icon"=>{"type"=>"emoji", "emoji"=>"✅"}}}]}}, {"type"=>"column", "object"=>"block", "column"=>{"children"=>[{"type"=>"callout", "object"=>"block", "callout"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Url callout", "link"=>nil}, "plain_text"=>"Url callout", "href"=>nil}], "color"=>"default", "icon"=>{"type"=>"external", "external"=>{"url"=>"https://img.icons8.com/ios-filled/250/000000/mac-os.png"}}}}]}}]}}
destroy → Block, String
destroy
sets the block archived flag to true.b = Block.new id: "7306e4c4bc5b48d78948e59ec0059afd" b.destroy
destroy dry_run: true
creates a shell script using Delete a block API for verification.block = Block.id "7306e4c4bc5b48d78948e59ec0059afd" b.destroy dry_run: true # => # #!/bin/sh # curl -X DELETE 'https://api.notion.com/v1/blocks/7306e4c4bc5b48d78948e59ec0059afd' \ # -H 'Notion-Version: 2022-02-22' \ # -H 'Authorization: Bearer '"$NOTION_API_KEY"''
divider → Block
divider
sets divider parameters to a plain block objectb = Block.new.divider; b.block_json # => {"type"=>"divider", "divider"=>{}}
embed(url, caption: []) → Block
- [PARAM] url embed url (String)
- [PARAM] caption
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
embed
sets embed parameters to a plain block objectb = Block.new.embed "https://twitter.com/hkob/status/1507972453095833601", caption: "NotionRubyMapping開発記録(21)"; b.block_json # => {"type"=>"embed", "object"=>"block", "embed"=>{"caption"=>[{"type"=>"text", "text"=>{"content"=>"NotionRubyMapping開発記録(21)", "link"=>nil}, "plain_text"=>"NotionRubyMapping開発記録(21)", "href"=>nil}], "url"=>"https://twitter.com/hkob/status/1507972453095833601"}}
equation(expression) → Block
- [PARAM] expression equation (String)
equation
sets equation parameters to a plain block objectb = Block.new.equation "x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"; b.block_json # => {"type"=>"equation", "object"=>"block", "equation"=>{"expression"=>"x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}"}}
file(url, caption: []) → Block
- [PARAM] url file url (String)
- [PARAM] caption
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
file
sets file parameters to a plain block object. Notion API can append or update an external file only.b = Block.new.file "https://img.icons8.com/ios-filled/250/000000/mac-os.png", caption: "macOS icon"; b.block_json # => {"type"=>"file", "object"=>"block", "file"=>{"type"=>"external", "external"=>{"url"=>"https://img.icons8.com/ios-filled/250/000000/mac-os.png"}, "caption"=>[{"type"=>"text", "text"=>{"content"=>"macOS icon", "link"=>nil}, "plain_text"=>"macOS icon", "href"=>nil}]}}
heading_1(text_info, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
heading_1
sets heading_1 parameters to a plain block objectb = Block.new.heading_1 "Heading 1", color: "orange_background"; b.block_json # => {"type"=>"heading_1", "object"=>"block", "heading_1"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Heading 1", "link"=>nil}, "plain_text"=>"Heading 1", "href"=>nil}], "color"=>"orange_background"}}
heading_2(text_info, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
heading_2
sets heading_ parameters to a plain block objectb = Block.new.heading_2 "Heading 2", color: "blue_background"; b.block_json # => {"type"=>"heading_2", "object"=>"block", "heading_2"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Heading 2", "link"=>nil}, "plain_text"=>"Heading 2", "href"=>nil}], "color"=>"blue_background"}}
heading_3(text_info, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
heading_3
sets heading_3 parameters to a plain block objectb = Block.new.heading_3 "Heading 3", color: "gray_background"; b.block_json # => {"type"=>"heading_3", "object"=>"block", "heading_3"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Heading 3", "link"=>nil}, "plain_text"=>"Heading 3", "href"=>nil}], "color"=>"gray_background"}}
image(url, caption: []) → Block
- [PARAM] url image url (String)
- [PARAM] caption
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
image
sets image parameters to a plain block object. Notion API can append or update an external file only.b = Block.new.image "https://cdn.worldvectorlogo.com/logos/notion-logo-1.svg", caption: "Notion log o"; b.block_json # => {"type"=>"image", "object"=>"block", "image"=>{"type"=>"external", "external"=>{"url"=>"https://cdn.worldvectorlogo.com/logos/notion-logo-1.svg"}, "caption"=>[{"type"=>"text", "text"=>{"content"=>"Notion logo", "link"=>nil}, "plain_text"=>"Notion logo", "href"=>nil}]}}
link_to_page(page_id: nil, database_id: nil) → Block
- [PARAM] page_id Identifier for a page
- [PARAM] database_id Identifier for a database
link_to_page
sets link_to_page parameters to a plain block object### for page_id b = Block.new.link_to_page page_id: "a_page_id"; b.block_json # => {"type"=>"link_to_page", "object"=>"block", "link_to_page"=>{"type"=>"page_id", "page_id"=>"a_page_id"}} ### for database_id b = Block.new.link_to_page database_id: "a_database_id"; b.block_json # => {"type"=>"link_to_page", "object"=>"block", "link_to_page"=>{"type"=>"database_id", "database_id"=>"a_database_id"}}
numbered_list_item(text_info, sub_blocks: nil, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
- This block can have children blocks.
numbered_list_item
sets numbered_list_item parameters to a plain block objectb = Block.new.numbered_list_item "Numbered list item", color: "red"; b.block_json # => {"type"=>"numbered_list_item", "object"=>"block", "numbered_list_item"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Numbered list item", "link"=>nil}, "plain_text"=>"Numbered list item", "href"=>nil}], "color"=>"red"}}⏎
paragraph(text_info, sub_blocks: nil, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
- This block can have children blocks.
paragraph
sets paragraph parameters to a plain block objectb = Block.new.paragraph "a sample paragraph", color: "yellow_background"; b.block_json # => {"type"=>"paragraph", "object"=>"block", "paragraph"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"a sample paragraph", "link"=>nil}, "plain_text"=>"a sample paragraph", "href"=>nil}], "color"=>"yellow_background"}}
pdf(url) → Block
- [PARAM] url url for external pdf files
pdf
sets pdf parameters to a plain block objectb = Block.new.pdf "https://github.com/onocom/sample-files-for-demo-use/raw/151dd797d54d7e0ae0dc50e8e19d7965b387e202/sample-pdf.pdf" # => {"type"=>"pdf", "object"=>"block", "pdf"=>{"type"=>"external", "external"=>{"url"=>"https://github.com/onocom/sample-files-for-demo-use/raw/151dd797d54d7e0ae0dc50e8e19d7965b387e202/sample-pdf.pdf"}}}
quote(text_info, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
- This block can have children blocks.
quote
sets quote parameters to a plain block objectb = Block.new.quote "A sample quote", color: "purple"; b.block_json # {"type"=>"quote", "object"=>"block", "quote"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"A sample quote", "link"=>nil}, "plain_text"=>"A sample quote", "href"=>nil}], "color"=>"purple"}}
synced_block(sub_blocks: nil, block_id: nil) → Block
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM] block_id id of the original synced_block (String)
blocks
orblock_id
cannot set at the same time.
synced_block
sets synced block parameters to a plain block object### original synced block b = Block.new.synced_block blocks: [ Block.new.bulleted_list_item("Synced block"), Block.new.divider, ] b.block_json # => {"type"=>"synced_block", "object"=>"block", "synced_block"=>{"synced_from"=>nil, "children"=>[{"type"=>"bulleted_list_item", "object"=>"block", "bulleted_list_item"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Synced block", "link"=>nil}, "plain_text"=>"Synced block", "href"=>nil}], "color"=>"default"}}, {"type"=>"divider", "object"=>"block", "divider"=>{}}]}} ### copy syned block b = Block.new.synced_block block_id: "4815032e-6f24-43e4-bc8c-9bdc6299b090"; b.block_json # => {"type"=>"synced_block", "object"=>"block", "synced_block"=>{"synced_from"=>{"type"=>"block_id", "block_id"=>"4815032e-6f24-43e4-bc8c-9bdc6299b090"}}}
table(table_width:, table_rows:, has_column_header: false, has_row_header: false) → Block
- [PARAM] table_width table width
- [PARAM] table_rows table_rows is an array of table_rows. An table row is an array of cells. A cell can be a string, an array of strings, a RichTextObject, or an array of RichTextObjects.
- [PARAM (optional)] has_column_header true if the table has column header
- [PARAM (optional)] has_row_header true if the table has row header
table
sets table parameters and table_rows to a plain block object. the table must have at least 1 table_row whose cells array has the same length as the table_width.b = Block.new.table has_column_header: true, has_row_header: true, table_width: 2, table_rows: [ %w[Services Account], [ "Twitter", ["hkob\n", TextObject.new("profile", "href" => "https://twitter.com/hkob/")], ], [ "GitHub", ["hkob\n", TextObject.new("repositories", "href" => "https://github.com/hkob/")], ], ]; b.block_json # => {"type"=>"table", "object"=>"block", "table"=>{"has_column_header"=>true, "has_row_header"=>true, "table_width"=>2, "children"=>[{"type"=>"table_row", "object"=>"block", "table_row"=>{"cells"=>[[{"type"=>"text", "text"=>{"content"=>"Services", "link"=>nil}, "plain_text"=>"Services", "href"=>nil}], [{"type"=>"text", "text"=>{"content"=>"Account", "link"=>nil}, "plain_text"=>"Account", "href"=>nil}]]}}, {"type"=>"table_row", "object"=>"block", "table_row"=>{"cells"=>[[{"type"=>"text", "text"=>{"content"=>"Twitter", "link"=>nil}, "plain_text"=>"Twitter", "href"=>nil}], [{"type"=>"text", "text"=>{"content"=>"hkob\n", "link"=>nil}, "plain_text"=>"hkob\n", "href"=>nil}, {"type"=>"text", "text"=>{"content"=>"profile", "link"=>{"url"=>"https://twitter.com/hkob/"}}, "plain_text"=>"profile", "href"=>"https://twitter.com/hkob/"}]]}}, {"type"=>"table_row", "object"=>"block", "table_row"=>{"cells"=>[[{"type"=>"text", "text"=>{"content"=>"GitHub", "link"=>nil}, "plain_text"=>"GitHub", "href"=>nil}], [{"type"=>"text", "text"=>{"content"=>"hkob\n", "link"=>nil}, "plain_text"=>"hkob\n", "href"=>nil}, {"type"=>"text", "text"=>{"content"=>"repositories", "link"=>{"url"=>"https://github.com/hkob/"}}, "plain_text"=>"repositories", "href"=>"https://github.com/hkob/"}]]}}]}}
table_of_contents(color: “default”) → Block
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
table_of_contents
sets table_of_contents parameters to a plain block objectb = Block.new.table_of_contents color: "pink" # => {"type"=>"table_of_contents", "object"=>"block", "table_of_contents"=>{"color"=>"pink"}}
template(text_info, sub_blocks: nil) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- This block can have children blocks.
template
sets breadcrumb parameters to a plain block objectb = Block.new.template "A sample template"; b.block_json # => {"type"=>"template", "object"=>"block", "template"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"A sample template", "link"=>nil}, "plain_text"=>"A sample template", "href"=>nil}]}}
to_do(text_info, checked: false, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM] checked true if checked (Boolean)
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
to_do
sets to do parameters to a plain block objectb = Block.new.to_do "A sample To-Do", color: "brown_background"; b.block_json # => {"type"=>"to_do", "object"=>"block", "to_do"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"A sample To-Do", "link"=>nil}, "plain_text"=>"A sample To-Do", "href"=>nil}], "checked"=>false, "color"=>"brown_background"}}
toggle(text_info, sub_blocks: nil, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
- This block can have children blocks.
template
sets breadcrumb parameters to a plain block objectb = Block.new.toggle "A sample toggle", color: "yellow_background"; b.block_json # => {"type"=>"toggle", "object"=>"block", "toggle"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"A sample toggle", "link"=>nil}, "plain_text"=>"A sample toggle", "href"=>nil}], "color"=>"yellow_background"}}
toggle_heading_1(text_info, sub_blocks: nil, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
toggle_heading_1
sets heading_1 parameters to a plain block objectb = Block.new.heading_1 "Heading 1", color: "orange_background"; b.block_json # => {"type"=>"heading_1", "object"=>"block", "heading_1"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Heading 1", "link"=>nil}, "plain_text"=>"Heading 1", "href"=>nil}], "color"=>"orange_background"}}
toggle_heading_2(text_info, sub_blocks: nil, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
toggle_heading_2
sets heading_ parameters to a plain block objectb = Block.new.heading_2 "Heading 2", color: "blue_background"; b.block_json # => {"type"=>"heading_2", "object"=>"block", "heading_2"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Heading 2", "link"=>nil}, "plain_text"=>"Heading 2", "href"=>nil}], "color"=>"blue_background"}}
toggle_heading_3(text_info, sub_blocks: nil, color: “default”) → Block
- [PARAM] text_info
- a String like as “text” (String)
- an Array of Strings (Array of Strings)
- a RichTextObject (RichTextObject)
- an Array of RichTextObjects (Array of RichTextObjects)
- a RichTextArray (RichTextArray)
The following objects are used for this argument.
- [PARAM(optional)] sub_blocks
children blocks (Array of Blocks). In
append block children API
, there is a limit for nesting children as follows. So, children blocks can not have any children.
For blocks that allow children, we allow up to two levels of nesting in a single request.
- [PARAM(optional)] color color string. When a_color is not specified, use “default”
toggle_heading_3
sets heading_3 parameters to a plain block objectb = Block.new.heading_3 "Heading 3", color: "gray_background"; b.block_json # => {"type"=>"heading_3", "object"=>"block", "heading_3"=>{"rich_text"=>[{"type"=>"text", "text"=>{"content"=>"Heading 3", "link"=>nil}, "plain_text"=>"Heading 3", "href"=>nil}], "color"=>"gray_background"}}
save(dry_run: false)
- [PARAM] dry_run: true if you want to create a verification script
save
updates the Block object with update block API
. The updated object has block information generated from the JSON response.block = Block.find "899e342cec84415f9ff86225704cbb75" # Notion API call block.url = "https://www.apple.com/" block.save # => #<NotionRubyMapping::Block:...> # updated Block object
Block.find(id, dry_run: true)
creates a shell script using Retrieve a block API for verification.block = Block.find "899e342cec84415f9ff86225704cbb75" # Notion API call block.url = "https://www.apple.com/" block.save dry_run: true # => # curl -X PATCH 'https://api.notion.com/v1/blocks/899e342cec84415f9ff86225704cbb75' \ # -H 'Notion-Version: 2022-02-22' \ # -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \ # -H 'Content-Type: application/json' \ # --data '{"bookmark":{"url":"https://www.apple.com/"}}'
video(url) → Block
- [PARAM] url video’s url
video
set video parameters to a plain block objectb = Block.new.video