Module: Notion::Http::Endpoints::PageMethods

Included in:
Client
Defined in:
lib/notion/http/endpoints/page_methods.rb

Overview

Notion::Http::Client.new.retrieve_a_page(page_id)

Instance Method Summary collapse

Instance Method Details

#create_a_page(options = {}) ⇒ Object

Creates a new page that is a child of an existing page.



24
25
26
27
28
29
30
31
# File 'lib/notion/http/endpoints/page_methods.rb', line 24

def create_a_page(options = {})
  if options.dig(:parent, :page_id).nil? && options.dig(:parent, :database_id).nil?
    raise Notion::Errors::ParamError, "Missing required params :parent.page_id or :parent.database_id"
  end
  raise Notion::Errors::ParamError, "Missing required params :parent.properties" if options[:properties].nil?

  post("pages", options)
end

#retrieve_a_page(options = {}) ⇒ Object

Retrieves a Page object using the ID specified.



9
10
11
12
13
# File 'lib/notion/http/endpoints/page_methods.rb', line 9

def retrieve_a_page(options = {})
  raise Notion::Errors::ParamError, "Missing required params :page_id" if options[:page_id].nil?

  get("pages/#{options[:page_id]}")
end

#retrieve_a_page_property_item(options = {}) ⇒ Object

Retrieves a property_item object for a given page_id and property_id.



16
17
18
19
20
21
# File 'lib/notion/http/endpoints/page_methods.rb', line 16

def retrieve_a_page_property_item(options = {})
  raise Notion::Errors::ParamError, "Missing required params :page_id" if options[:page_id].nil?
  raise Notion::Errors::ParamError, "Missing required params :property_id" if options[:property_id].nil?

  get("pages/#{options[:page_id]}/properties/#{options[:property_id]}")
end

#update_page(options = {}) ⇒ Object

Updates the properties of a page in a database.



34
35
36
37
38
39
# File 'lib/notion/http/endpoints/page_methods.rb', line 34

def update_page(options = {})
  raise Notion::Errors::ParamError, "Missing required params :page_id" if options[:page_id].nil?

  page_id = options.delete(:page_id)
  patch("pages/#{page_id}", options)
end