Module: Notion::Api::Endpoints::Comments
- Included in:
- Notion::Api::Endpoints
- Defined in:
- lib/notion/api/endpoints/comments.rb
Instance Method Summary collapse
-
#create_comment(options = {}) ⇒ Object
Creates a comment in a page or existing discussion thread.
-
#retrieve_comments(options = {}) ⇒ Object
Retrieves a list of un-resolved Comment objects from a page or block.
Instance Method Details
#create_comment(options = {}) ⇒ Object
Creates a comment in a page or existing discussion thread.
There are two locations you can add a new comment to:
- A page
- An existing discussion thread
If the intention is to add a new comment to a page, a parent object
must be provided in the body params. Alternatively, if a new comment
is being added to an existing discussion thread, the discussion_id string
must be provided in the body params. Exactly one of these parameters must be provided.
51 52 53 54 55 56 57 |
# File 'lib/notion/api/endpoints/comments.rb', line 51 def create_comment( = {}) if .dig(:parent, :page_id).nil? && [:discussion_id].nil? throw ArgumentError.new('Required argument :page_id or :discussion_id missing') end throw ArgumentError.new('Required argument :rich_text missing') if [:rich_text].nil? post('comments', ) end |
#retrieve_comments(options = {}) ⇒ Object
Retrieves a list of un-resolved Comment objects from a page or block.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/notion/api/endpoints/comments.rb', line 22 def retrieve_comments( = {}) throw ArgumentError.new('Required arguments :block_id missing') if [:block_id].nil? if block_given? Pagination::Cursor.new(self, :retrieve_comments, ).each do |page| yield page end else get('comments', ) end end |