Class: Notion::Generated::Endpoints::Pages

Inherits:
Endpoints::Base show all
Defined in:
lib/notion/endpoints/pages.rb,
lib/notion/generated/endpoints/pages.rb

Instance Method Summary collapse

Methods inherited from Endpoints::Base

#initialize, operation, operations

Constructor Details

This class inherits a constructor from Notion::Endpoints::Base

Instance Method Details

#create(parent:, **params, &block) ⇒ Object

Create a page



19
20
21
22
23
24
25
26
# File 'lib/notion/generated/endpoints/pages.rb', line 19

def create(parent:, **params)
  params[:parent] = parent
  properties = params[:properties]
  parent, data_source_id = normalize_parent(parent)
  params[:parent] = parent unless parent.empty?
  params[:properties] = convert(properties, data_source_id) if properties && data_source_id
  invoke_operation(:create, params)
end

#markdown(page_id:, **params, &block) ⇒ Object

Retrieve a page as markdown



51
52
53
54
# File 'lib/notion/generated/endpoints/pages.rb', line 51

def markdown(page_id:, **params, &block)
    params[:page_id] = page_id
  invoke_operation(:markdown, params, &block)
end

#move(page_id:, parent:, **params, &block) ⇒ Object

Move a page



37
38
39
40
41
# File 'lib/notion/generated/endpoints/pages.rb', line 37

def move(page_id:, parent:, **params, &block)
    params[:page_id] = page_id
    params[:parent] = parent
  invoke_operation(:move, params, &block)
end

#retrieve(page_id:, **params, &block) ⇒ Object

Retrieve a page



25
26
27
28
# File 'lib/notion/generated/endpoints/pages.rb', line 25

def retrieve(page_id:, **params, &block)
    params[:page_id] = page_id
  invoke_operation(:retrieve, params, &block)
end

#retrieve_property(page_id:, property_id:, **params, &block) ⇒ Object

Retrieve a page property item



44
45
46
47
48
# File 'lib/notion/generated/endpoints/pages.rb', line 44

def retrieve_property(page_id:, property_id:, **params, &block)
    params[:page_id] = page_id
    params[:property_id] = property_id
  invoke_operation(:retrieve_property, params, &block)
end

#update(page_id:, **params, &block) ⇒ Object

Update page



31
32
33
34
35
36
37
38
39
40
# File 'lib/notion/generated/endpoints/pages.rb', line 31

def update(page_id:, **params)
  if primitive?(params[:properties])
    page = retrieve(page_id: page_id)
    parent = page.raw.fetch("parent", {})
    data_source_id = parent["data_source_id"] || parent["database_id"]
    params[:properties] = convert(params[:properties], data_source_id)
  end
  params[:page_id] = page_id
  invoke_operation(:update, params)
end

#update_markdown(page_id:, type:, **params, &block) ⇒ Object

Update a page's content as markdown



57
58
59
60
61
# File 'lib/notion/generated/endpoints/pages.rb', line 57

def update_markdown(page_id:, type:, **params, &block)
    params[:page_id] = page_id
    params[:type] = type
  invoke_operation(:update_markdown, params, &block)
end