Class: Attio::Thread
- Inherits:
-
APIResource
- Object
- APIResource
- Attio::Thread
- Defined in:
- lib/attio/resources/thread.rb
Overview
Represents a comment thread in Attio (read-only)
Constant Summary
Constants inherited from APIResource
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
-
.list(**params) ⇒ Object
(also: all)
Custom list implementation to handle query params properly.
-
.resource_path ⇒ String
API endpoint path for threads.
Instance Method Summary collapse
-
#comment_count ⇒ Object
Helper methods for working with comments.
-
#destroy(**opts) ⇒ Object
Override destroy to raise error since threads are read-only.
-
#first_comment ⇒ Hash?
Get the first comment in the thread.
- #has_comments? ⇒ Boolean
-
#immutable? ⇒ Boolean
Threads are read-only.
-
#last_comment ⇒ Hash?
Get the last comment in the thread.
-
#save(**opts) ⇒ Object
Override save to raise error since threads are read-only.
Methods inherited from APIResource
#==, #[], #[]=, api_operations, attr_attio, #changed, #changed?, #changed_attributes, #changes, #each, execute_request, #fetch, #hash, id_param_name, #initialize, #key?, #keys, #persisted?, prepare_params_for_create, prepare_params_for_update, #reset_changes!, resource_name, #revert!, #to_json, #update_attributes, #update_from, validate_id!, #values
Constructor Details
This class inherits a constructor from Attio::APIResource
Class Method Details
.list(**params) ⇒ Object Also known as: all
Custom list implementation to handle query params properly
19 20 21 22 23 24 25 26 |
# File 'lib/attio/resources/thread.rb', line 19 def self.list(**params) # Query params should be part of the request, not opts query_params = params.slice(:record_id, :object, :entry_id, :list, :limit, :offset) opts = params.except(:record_id, :object, :entry_id, :list, :limit, :offset) response = execute_request(:GET, resource_path, query_params, opts) ListObject.new(response, self, params, opts) end |
.resource_path ⇒ String
API endpoint path for threads
14 15 16 |
# File 'lib/attio/resources/thread.rb', line 14 def self.resource_path "threads" end |
Instance Method Details
#comment_count ⇒ Object
Helper methods for working with comments
36 37 38 |
# File 'lib/attio/resources/thread.rb', line 36 def comment_count comments&.length || 0 end |
#destroy(**opts) ⇒ Object
Override destroy to raise error since threads are read-only
67 68 69 |
# File 'lib/attio/resources/thread.rb', line 67 def destroy(**opts) raise InvalidRequestError, "Threads are read-only and cannot be deleted" end |
#first_comment ⇒ Hash?
Get the first comment in the thread
46 47 48 |
# File 'lib/attio/resources/thread.rb', line 46 def first_comment comments&.first end |
#has_comments? ⇒ Boolean
40 41 42 |
# File 'lib/attio/resources/thread.rb', line 40 def has_comments? comment_count > 0 end |
#immutable? ⇒ Boolean
Threads are read-only
57 58 59 |
# File 'lib/attio/resources/thread.rb', line 57 def immutable? true end |
#last_comment ⇒ Hash?
Get the last comment in the thread
52 53 54 |
# File 'lib/attio/resources/thread.rb', line 52 def last_comment comments&.last end |
#save(**opts) ⇒ Object
Override save to raise error since threads are read-only
62 63 64 |
# File 'lib/attio/resources/thread.rb', line 62 def save(**opts) raise InvalidRequestError, "Threads are read-only and cannot be modified" end |