Class: NotionRubyMapping::DiscussionThread

Inherits:
Object
  • Object
show all
Defined in:
lib/notion_ruby_mapping/controllers/discussion_thread.rb

Overview

DiscussionThread

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(discussion_id) ⇒ DiscussionThread

Returns a new instance of DiscussionThread.

Parameters:

  • discussion_id (String)


7
8
9
10
# File 'lib/notion_ruby_mapping/controllers/discussion_thread.rb', line 7

def initialize(discussion_id)
  @discussion_id = discussion_id
  @comments = []
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



11
12
13
# File 'lib/notion_ruby_mapping/controllers/discussion_thread.rb', line 11

def comments
  @comments
end

#discussion_idObject (readonly)

Returns the value of attribute discussion_id.



11
12
13
# File 'lib/notion_ruby_mapping/controllers/discussion_thread.rb', line 11

def discussion_id
  @discussion_id
end

Instance Method Details

#append_comment(text_objects, dry_run: false) ⇒ String, NotionRubyMapping::CommentObject

Parameters:

  • text_objects (String)
  • dry_run (Boolean) (defaults to: false)

    true if dry_run

Returns:



16
17
18
19
20
21
22
23
24
25
# File 'lib/notion_ruby_mapping/controllers/discussion_thread.rb', line 16

def append_comment(text_objects, dry_run: false)
  rto = RichTextArray.new "rich_text", text_objects: text_objects, will_update: true
  nc = NotionCache.instance
  json = rto.property_schema_json.merge({discussion_id: @discussion_id})
  if dry_run
    Base.dry_run_script :post, nc.comments_path, json
  else
    CommentObject.new json: (nc.append_comment_request json)
  end
end