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
-
#create_a_page(options = {}) ⇒ Object
Creates a new page that is a child of an existing page.
-
#retrieve_a_page(options = {}) ⇒ Object
Retrieves a Page object using the ID specified.
-
#retrieve_a_page_property_item(options = {}) ⇒ Object
Retrieves a property_item object for a given page_id and property_id.
-
#update_page(options = {}) ⇒ Object
Updates the properties of a page in a database.
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( = {}) if .dig(:parent, :page_id).nil? && .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 [:properties].nil? post("pages", ) 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( = {}) raise Notion::Errors::ParamError, "Missing required params :page_id" if [:page_id].nil? get("pages/#{[: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( = {}) raise Notion::Errors::ParamError, "Missing required params :page_id" if [:page_id].nil? raise Notion::Errors::ParamError, "Missing required params :property_id" if [:property_id].nil? get("pages/#{[:page_id]}/properties/#{[: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( = {}) raise Notion::Errors::ParamError, "Missing required params :page_id" if [:page_id].nil? page_id = .delete(:page_id) patch("pages/#{page_id}", ) end |