Module: Notion::Api::Endpoints::Pages
- Included in:
- Notion::Api::Endpoints
- Defined in:
- lib/notion/api/endpoints/pages.rb
Instance Method Summary collapse
-
#create_page(options = {}) ⇒ Object
Creates a new page in the specified database.
-
#page(options = {}) ⇒ Object
Retrieves a 📄Page object using the ID specified in the request path.
-
#page_property_item(options = {}) ⇒ Object
Retrieves a ‘property_item` object for a given `page_id` and `property_id`.
-
#update_page(options = {}) ⇒ Object
Updates a page by setting the values of any properties specified in the JSON body of the request.
Instance Method Details
#create_page(options = {}) ⇒ Object
Creates a new page in the specified database. Later iterations of the API will support creating pages outside databases. Note that this iteration of the API will only expose page properties, not page content, as described in the data model.
40 41 42 43 44 45 46 |
# File 'lib/notion/api/endpoints/pages.rb', line 40 def create_page( = {}) if .dig(:parent, :database_id).nil? && .dig(:parent, :page_id).nil? throw ArgumentError.new('Required argument :parent.database_id or :parent.page_id required') end post("pages", ) end |
#page(options = {}) ⇒ Object
Retrieves a 📄Page object using the ID specified in the request path. Note that this version of the API only exposes page properties, not page content
17 18 19 20 |
# File 'lib/notion/api/endpoints/pages.rb', line 17 def page( = {}) throw ArgumentError.new('Required argument :page_id missing') if [:page_id].nil? get("pages/#{[:page_id]}") end |
#page_property_item(options = {}) ⇒ Object
Retrieves a ‘property_item` object for a given `page_id` and `property_id`. Depending on the property type, the object returned will either be a value or a paginated list of property item values.
82 83 84 85 86 |
# File 'lib/notion/api/endpoints/pages.rb', line 82 def page_property_item( = {}) throw ArgumentError.new('Required argument :page_id missing') if [:page_id].nil? throw ArgumentError.new('Required argument :property_id missing') if [:property_id].nil? get("pages/#{[:page_id]}/properties/#{[:property_id]}") end |
#update_page(options = {}) ⇒ Object
Updates a page by setting the values of any properties specified in the JSON body of the request. Properties that are not set via parameters will remain unchanged.
Note that this iteration of the API will only expose page properties, not page content, as described in the data model.
65 66 67 68 69 |
# File 'lib/notion/api/endpoints/pages.rb', line 65 def update_page( = {}) page_id = .delete(:page_id) throw ArgumentError.new('Required argument :page_id missing') if page_id.nil? patch("pages/#{page_id}", ) end |