Module: Notion::Api::Endpoints::Blocks

Included in:
Notion::Api::Endpoints
Defined in:
lib/notion/api/endpoints/blocks.rb

Instance Method Summary collapse

Instance Method Details

#block_append_children(options = {}) ⇒ Object

Creates and appends new children blocks to the parent block in the requested path using the ID specified. Returns the Block object being appended to.

Returns a 404 HTTP response if any of the following are true:

  • the ID does not exist

  • the bot doesn’t have access to the block with the given ID

Returns a 400 or 429 HTTP response if the request exceeds Notion’s Request limits.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (id)

    Block to get children info on.

  • :children ([Object])

    Children blocks to append



46
47
48
49
# File 'lib/notion/api/endpoints/blocks.rb', line 46

def block_append_children(options = {})
  throw ArgumentError.new('Required arguments :id missing') if options[:id].nil?
  patch("blocks/#{options[:id]}/children", options)
end

#block_children(options = {}) ⇒ Object

Returns a paginated array of Block objects contained in the block of the requested path using the ID specified.

Returns a 404 HTTP response if any of the following are true:

  • the ID does not exist

  • the bot doesn’t have access to the block with the given ID

Returns a 400 or 429 HTTP response if the request exceeds Notion’s Request limits.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (id)

    Block to get children info on.



19
20
21
22
23
24
25
26
27
28
# File 'lib/notion/api/endpoints/blocks.rb', line 19

def block_children(options = {})
  throw ArgumentError.new('Required arguments :id missing') if options[:id].nil?
  if block_given?
    Pagination::Cursor.new(self, :block_children, options).each do |page|
      yield page
    end
  else
    get("blocks/#{options[:id]}/children", options)
  end
end