Class: NotionAPI::TodoBlock
- Inherits:
-
BlockTemplate
- Object
- Core
- BlockTemplate
- NotionAPI::TodoBlock
- Defined in:
- lib/notion_api/notion_types/todo_block.rb
Overview
To-Do block: best for checklists and tracking to-dos.
Constant Summary
Constants included from Utils
Class Attribute Summary collapse
-
.notion_type ⇒ Object
readonly
Returns the value of attribute notion_type.
-
.type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from BlockTemplate
Attributes inherited from Core
Instance Method Summary collapse
Methods inherited from BlockTemplate
#convert, #create, #duplicate, #initialize, #move
Methods included from Utils
Methods inherited from Core
#children, #children_ids, #get_page, #initialize
Constructor Details
This class inherits a constructor from NotionAPI::BlockTemplate
Class Attribute Details
.notion_type ⇒ Object (readonly)
Returns the value of attribute notion_type.
13 14 15 |
# File 'lib/notion_api/notion_types/todo_block.rb', line 13 def notion_type @notion_type end |
.type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/notion_api/notion_types/todo_block.rb', line 13 def type @type end |
Instance Method Details
#checked=(checked_value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/notion_api/notion_types/todo_block.rb', line 16 def checked=(checked_value) # ! change the checked property of the Todo Block. # ! checked_value -> boolean value used to determine whether the block should be checked [yes] or not [no] : ``str`` # set static variables for request = Core.["cookies"] headers = Core.["headers"] request_url = URLS[:UPDATE_BLOCK] # set unique values for request request_id = extract_id(SecureRandom.hex(16)) transaction_id = extract_id(SecureRandom.hex(16)) space_id = extract_id(SecureRandom.hex(16)) request_ids = { request_id: request_id, transaction_id: transaction_id, space_id: space_id, } if %w[yes no].include?(checked_value.downcase) checked_hash = Utils::BlockComponents.checked_todo(@id, checked_value.downcase) last_edited_time_parent_hash = Utils::BlockComponents.last_edited_time(@parent_id) last_edited_time_child_hash = Utils::BlockComponents.last_edited_time(@id) operations = [ checked_hash, last_edited_time_parent_hash, last_edited_time_child_hash, ] request_body = build_payload(operations, request_ids) response = HTTParty.post( request_url, body: request_body.to_json, cookies: , headers: headers, ) unless response.code == 200; raise "There was an issue completing your request. Here is the response from Notion: #{response.body}, and here is the payload that was sent: #{operations}. Please try again, and if issues persist open an issue in GitHub."; end true else false end end |
#type ⇒ Object
8 9 10 |
# File 'lib/notion_api/notion_types/todo_block.rb', line 8 def type NotionAPI::TodoBlock.notion_type end |