<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(color = "default") → TableOfContentsBlock

self.new creates a TableOfContentsBlock. The block cannot have child blocks.

block = TableOfContentsBlock.new "green_background"
block.block_json
# => {"type"=>"table_of_contents", "object"=>"block", "table_of_contents"=>{"color"=>"green_background"}}

2. Instance methods

color → String

color returns the current color of the TableOfContentsBlock.

block = TableOfContentsBlock.new "green_background"
block.color
# => "green_background"

color=(new_color)

color= changes the color and marks color for the next block update. NotionRubyMapping does not validate the value; specify a color supported by the Notion API.

block = TableOfContentsBlock.new "green_background"
block.color = "orange_background"
block.update_block_json
# => {"table_of_contents"=>{"color"=>"orange_background"}}

save(dry_run: false) → TableOfContentsBlock, String

$\fbox{implemented in Block}$

save sends the pending color change to the Notion API. Without dry_run, it returns the updated TableOfContentsBlock created from the API response.

block = Block.find "b3c6fe0a5885498aa5cb4c4b3080f4cf"
block.color = "orange_background"
block.save
# => #<NotionRubyMapping::TableOfContentsBlock:...>

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

block.color = "orange_background"
block.save dry_run: true
# => "#!/bin/sh\n# curl -X PATCH ..."