Class: Attio::Resources::Comments Private
- Defined in:
- lib/attio/resources/comments.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
API resource for managing comments in Attio
Comments can be added to records and threads for collaboration.
Instance Method Summary collapse
-
#create(content:, parent_object: nil, parent_record_id: nil, thread_id: nil, **data) ⇒ Hash
private
Create a new comment.
-
#delete(id:) ⇒ Hash
private
Delete a comment.
-
#get(id:) ⇒ Hash
private
Get a specific comment by ID.
-
#list(**params) ⇒ Hash
private
List comments for a parent record or thread.
-
#react(id:, emoji:) ⇒ Hash
private
React to a comment with an emoji.
-
#unreact(id:, emoji:) ⇒ Hash
private
Remove a reaction from a comment.
-
#update(id:, content:) ⇒ Hash
private
Update an existing comment.
- #validate_create_params!(parent_object, parent_record_id, thread_id) ⇒ Object private private
- #validate_list_params!(params) ⇒ Object private private
Constructor Details
This class inherits a constructor from Attio::Resources::Base
Instance Method Details
#create(content:, parent_object: nil, parent_record_id: nil, thread_id: nil, **data) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new comment
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/attio/resources/comments.rb', line 58 def create(content:, parent_object: nil, parent_record_id: nil, thread_id: nil, **data) validate_required_string!(content, "Comment content") validate_create_params!(parent_object, parent_record_id, thread_id) params = data.merge(content: content) if thread_id params[:thread_id] = thread_id else params[:parent_object] = parent_object params[:parent_record_id] = parent_record_id end request(:post, "comments", params) end |
#delete(id:) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Delete a comment
93 94 95 96 |
# File 'lib/attio/resources/comments.rb', line 93 def delete(id:) validate_id!(id, "Comment") request(:delete, "comments/#{id}") end |
#get(id:) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a specific comment by ID
43 44 45 46 |
# File 'lib/attio/resources/comments.rb', line 43 def get(id:) validate_id!(id, "Comment") request(:get, "comments/#{id}") end |
#list(**params) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
List comments for a parent record or thread
32 33 34 35 |
# File 'lib/attio/resources/comments.rb', line 32 def list(**params) validate_list_params!(params) request(:get, "comments", params) end |
#react(id:, emoji:) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
React to a comment with an emoji
105 106 107 108 109 |
# File 'lib/attio/resources/comments.rb', line 105 def react(id:, emoji:) validate_id!(id, "Comment") validate_required_string!(emoji, "Emoji") request(:post, "comments/#{id}/reactions", { emoji: emoji }) end |
#unreact(id:, emoji:) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Remove a reaction from a comment
118 119 120 121 122 |
# File 'lib/attio/resources/comments.rb', line 118 def unreact(id:, emoji:) validate_id!(id, "Comment") validate_required_string!(emoji, "Emoji") request(:delete, "comments/#{id}/reactions/#{CGI.escape(emoji)}") end |
#update(id:, content:) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Update an existing comment
81 82 83 84 85 |
# File 'lib/attio/resources/comments.rb', line 81 def update(id:, content:) validate_id!(id, "Comment") validate_required_string!(content, "Comment content") request(:patch, "comments/#{id}", { content: content }) end |
#validate_create_params!(parent_object, parent_record_id, thread_id) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/attio/resources/comments.rb', line 133 private def validate_create_params!(parent_object, parent_record_id, thread_id) has_parent = parent_object && parent_record_id has_thread = thread_id unless has_parent || has_thread raise ArgumentError, "Must provide either parent_object/parent_record_id or thread_id" end return unless has_parent && has_thread raise ArgumentError, "Cannot provide both parent and thread parameters" end |
#validate_list_params!(params) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 125 126 127 128 129 130 131 |
# File 'lib/attio/resources/comments.rb', line 124 private def validate_list_params!(params) has_parent = params[:parent_object] && params[:parent_record_id] has_thread = params[:thread_id] return if has_parent || has_thread raise ArgumentError, "Must provide either parent_object/parent_record_id or thread_id" end |