Class: Attio::Resources::Comments Private

Inherits:
Base
  • Object
show all
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.

Examples:

Creating a comment on a record

client.comments.create(
  parent_object: "people",
  parent_record_id: "person_123",
  content: "Just had a great call with this lead!"
)

Creating a comment in a thread

client.comments.create(
  thread_id: "thread_456",
  content: "Following up on our discussion..."
)

Since:

  • 1.0.0

Instance Method Summary collapse

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

Parameters:

  • content (String)

    The comment content (supports markdown)

  • parent_object (String) (defaults to: nil)

    Parent object type (required if no thread_id)

  • parent_record_id (String) (defaults to: nil)

    Parent record ID (required if no thread_id)

  • thread_id (String) (defaults to: nil)

    Thread ID (required if no parent_object/parent_record_id)

  • data (Hash)

    Additional comment data

Returns:

  • (Hash)

    The created comment

Raises:

  • (ArgumentError)

    if required parameters are missing

Since:

  • 1.0.0



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

Parameters:

  • id (String)

    The comment ID to delete

Returns:

  • (Hash)

    Deletion confirmation

Raises:

  • (ArgumentError)

    if id is nil or empty

Since:

  • 1.0.0



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

Parameters:

  • id (String)

    The comment ID

Returns:

  • (Hash)

    The comment data

Raises:

  • (ArgumentError)

    if id is nil or empty

Since:

  • 1.0.0



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

Parameters:

  • params (Hash)

    Query parameters

Options Hash (**params):

  • :parent_object (String)

    Parent object type

  • :parent_record_id (String)

    Parent record ID

  • :thread_id (String)

    Thread ID

  • :limit (Integer)

    Number of comments to return

  • :cursor (String)

    Pagination cursor

Returns:

  • (Hash)

    API response containing comments

Since:

  • 1.0.0



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

Parameters:

  • id (String)

    The comment ID

  • emoji (String)

    The emoji reaction (e.g., "👍", "❤️")

Returns:

  • (Hash)

    The updated comment with reaction

Raises:

  • (ArgumentError)

    if id or emoji is invalid

Since:

  • 1.0.0



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

Parameters:

  • id (String)

    The comment ID

  • emoji (String)

    The emoji reaction to remove

Returns:

  • (Hash)

    The updated comment

Raises:

  • (ArgumentError)

    if id or emoji is invalid

Since:

  • 1.0.0



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

Parameters:

  • id (String)

    The comment ID

  • content (String)

    The new content

Returns:

  • (Hash)

    The updated comment

Raises:

  • (ArgumentError)

    if id or content is invalid

Since:

  • 1.0.0



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.

Raises:

  • (ArgumentError)

Since:

  • 1.0.0



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.

Raises:

  • (ArgumentError)

Since:

  • 1.0.0



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