Class: NotionAPI::TodoBlock
- Inherits:
-
BlockTemplate
- Object
- Core
- BlockTemplate
- NotionAPI::TodoBlock
- Defined in:
- lib/notion_api/blocks.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.
369 370 371 |
# File 'lib/notion_api/blocks.rb', line 369 def notion_type @notion_type end |
.type ⇒ Object (readonly)
Returns the value of attribute type.
369 370 371 |
# File 'lib/notion_api/blocks.rb', line 369 def type @type end |
Instance Method Details
#checked=(checked_value) ⇒ Object
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/notion_api/blocks.rb', line 372 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
364 365 366 |
# File 'lib/notion_api/blocks.rb', line 364 def type NotionAPI::TodoBlock.notion_type end |