Class: Attio::Resources::Threads Private

Inherits:
Base
  • Object
show all
Defined in:
lib/attio/resources/threads.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 threads in Attio

Threads represent conversations or discussion topics related to records.

Examples:

Listing threads for a record

client.threads.list(
  parent_object: "companies",
  parent_record_id: "company_123"
)

Getting a specific thread

client.threads.get(id: "thread_456")

Since:

  • 1.0.0

API:

  • private

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Attio::Resources::Base

Instance Method Details

#add_participants(id:, user_ids:) ⇒ 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.

Add participants to a thread

Parameters:

  • The thread ID

  • User IDs to add as participants

Returns:

  • The updated thread

Raises:

  • if id or user_ids is invalid

Since:

  • 1.0.0

API:

  • private



129
130
131
132
133
# File 'lib/attio/resources/threads.rb', line 129

def add_participants(id:, user_ids:)
  validate_id!(id, "Thread")
  validate_user_ids!(user_ids)
  request(:post, "threads/#{id}/participants", { user_ids: user_ids })
end

#close(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.

Close a thread

Parameters:

  • The thread ID

Returns:

  • The updated thread

Raises:

  • if id is nil or empty

Since:

  • 1.0.0

API:

  • private



95
96
97
98
# File 'lib/attio/resources/threads.rb', line 95

def close(id:)
  validate_id!(id, "Thread")
  request(:patch, "threads/#{id}", { status: "closed" })
end

#create(parent_object:, parent_record_id:, title:, **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 thread

Parameters:

  • The parent object type

  • The parent record ID

  • The thread title

  • Additional thread data

Options Hash (**data):

  • :description (String)

    Thread description

  • :status (String)

    Thread status (open, closed)

  • :participant_ids (Array<String>)

    User IDs of participants

Returns:

  • The created thread

Raises:

  • if required parameters are missing

Since:

  • 1.0.0

API:

  • private



62
63
64
65
66
67
68
69
70
71
# File 'lib/attio/resources/threads.rb', line 62

def create(parent_object:, parent_record_id:, title:, **data)
  validate_parent!(parent_object, parent_record_id)
  validate_required_string!(title, "Thread title")

  request(:post, "threads", data.merge(
                              parent_object: parent_object,
                              parent_record_id: parent_record_id,
                              title: title
                            ))
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 thread

Parameters:

  • The thread ID to delete

Returns:

  • Deletion confirmation

Raises:

  • if id is nil or empty

Since:

  • 1.0.0

API:

  • private



117
118
119
120
# File 'lib/attio/resources/threads.rb', line 117

def delete(id:)
  validate_id!(id, "Thread")
  request(:delete, "threads/#{id}")
end

#get(id:, include_comments: false) ⇒ 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 thread by ID

Parameters:

  • The thread ID

  • (defaults to: false)

    Whether to include comments in the response

Returns:

  • The thread data

Raises:

  • if id is nil or empty

Since:

  • 1.0.0

API:

  • private



44
45
46
47
48
# File 'lib/attio/resources/threads.rb', line 44

def get(id:, include_comments: false)
  validate_id!(id, "Thread")
  params = include_comments ? { include: "comments" } : {}
  request(:get, "threads/#{id}", params)
end

#list(parent_object:, parent_record_id:, **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 threads for a parent record

Parameters:

  • The parent object type

  • The parent record ID

  • Additional query parameters

Options Hash (**params):

  • :limit (Integer)

    Number of threads to return

  • :cursor (String)

    Pagination cursor

  • :status (String)

    Filter by status (open, closed)

Returns:

  • API response containing threads

Raises:

  • if parent_object or parent_record_id is missing

Since:

  • 1.0.0

API:

  • private



29
30
31
32
33
34
35
# File 'lib/attio/resources/threads.rb', line 29

def list(parent_object:, parent_record_id:, **params)
  validate_parent!(parent_object, parent_record_id)
  request(:get, "threads", params.merge(
                             parent_object: parent_object,
                             parent_record_id: parent_record_id
                           ))
end

#remove_participants(id:, user_ids:) ⇒ 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 participants from a thread

Parameters:

  • The thread ID

  • User IDs to remove

Returns:

  • The updated thread

Raises:

  • if id or user_ids is invalid

Since:

  • 1.0.0

API:

  • private



142
143
144
145
146
# File 'lib/attio/resources/threads.rb', line 142

def remove_participants(id:, user_ids:)
  validate_id!(id, "Thread")
  validate_user_ids!(user_ids)
  request(:delete, "threads/#{id}/participants", { user_ids: user_ids })
end

#reopen(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.

Reopen a closed thread

Parameters:

  • The thread ID

Returns:

  • The updated thread

Raises:

  • if id is nil or empty

Since:

  • 1.0.0

API:

  • private



106
107
108
109
# File 'lib/attio/resources/threads.rb', line 106

def reopen(id:)
  validate_id!(id, "Thread")
  request(:patch, "threads/#{id}", { status: "open" })
end

#update(id:, **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.

Update an existing thread

Parameters:

  • The thread ID

  • The fields to update

Options Hash (**data):

  • :title (String)

    New title

  • :description (String)

    New description

  • :status (String)

    New status (open, closed)

Returns:

  • The updated thread

Raises:

  • if id is invalid

Since:

  • 1.0.0

API:

  • private



83
84
85
86
87
# File 'lib/attio/resources/threads.rb', line 83

def update(id:, **data)
  validate_id!(id, "Thread")
  validate_data!(data, "Update")
  request(:patch, "threads/#{id}", data)
end

#validate_user_ids!(user_ids) ⇒ 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:

Since:

  • 1.0.0

API:

  • private



148
149
150
151
# File 'lib/attio/resources/threads.rb', line 148

private def validate_user_ids!(user_ids)
  raise ArgumentError, "User IDs are required" if user_ids.nil? || user_ids.empty?
  raise ArgumentError, "User IDs must be an array" unless user_ids.is_a?(Array)
end