Class: Layer::Conversation
- Extended by:
- Operations::Create::ClassMethods, Operations::Delete::ClassMethods, Operations::Destroy::ClassMethods, Operations::Find::ClassMethods, Operations::Paginate::ClassMethods
- Includes:
- Operations::Create, Operations::Delete, Operations::Destroy, Operations::Find, Operations::Paginate, Operations::Patch
- Defined in:
- lib/layer/conversation.rb
Overview
This is available in both the REST and the Platform API. Please refer to the respective documentation to see which methods are available.
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#contents ⇒ Layer::RelationProxy
Allows creating and finding of the conversation’s rich content.
-
#created_at ⇒ Time
Returns the time the conversation was created at.
-
#distinct? ⇒ Boolean
Whether the conversation is distinct.
-
#messages ⇒ Layer::RelationProxy
Returns the conversations messages.
-
#metadata ⇒ Layer::Patch::Hash
Returns the conversations metadata.
-
#participants ⇒ Layer::Patch::Array
Returns the conversations metadata.
Methods included from Operations::Find::ClassMethods
Methods included from Operations::Paginate::ClassMethods
Methods included from Operations::Create::ClassMethods
Methods included from Operations::Delete::ClassMethods
Methods included from Operations::Destroy::ClassMethods
Methods included from Operations::Patch
Methods included from Operations::Destroy
Methods included from Operations::Delete
Methods included from Operations::Find
Methods inherited from Resource
class_name, from_response, #id, #initialize, #respond_to_missing?, url, #url
Constructor Details
This class inherits a constructor from Layer::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Layer::Resource
Instance Method Details
#contents ⇒ Layer::RelationProxy
This is only available via the Platform API.
Allows creating and finding of the conversation’s rich content
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/layer/conversation.rb', line 43 def contents RelationProxy.new(self, Content, [Operations::Create, Operations::Find]) do def create(mime_type, file, client = self.client) response = client.post(url, {}, { 'Upload-Content-Type' => mime_type, 'Upload-Content-Length' => file.size }) attributes = response.merge('size' => file.size, 'mime_type' => mime_type) Content.from_response(attributes, client).tap do |content| content.upload(file) end end end end |
#created_at ⇒ Time
Returns the time the conversation was created at
86 87 88 |
# File 'lib/layer/conversation.rb', line 86 def created_at Time.parse(attributes['created_at']) end |
#distinct? ⇒ Boolean
Whether the conversation is distinct
79 80 81 |
# File 'lib/layer/conversation.rb', line 79 def distinct? attributes['distinct'] end |
#messages ⇒ Layer::RelationProxy
This is available in both the REST and the Platform API. Please refer to the respective documentation to see which methods are available.
Returns the conversations messages
35 36 37 |
# File 'lib/layer/conversation.rb', line 35 def RelationProxy.new(self, Message, [Operations::Create, Operations::Paginate, Operations::Find, Operations::Delete, Operations::Destroy]) end |
#metadata ⇒ Layer::Patch::Hash
Returns the conversations metadata
63 64 65 66 |
# File 'lib/layer/conversation.rb', line 63 def attributes['metadata'] ||= {} attributes['metadata'] end |
#participants ⇒ Layer::Patch::Array
Returns the conversations metadata
71 72 73 74 |
# File 'lib/layer/conversation.rb', line 71 def participants attributes['participants'] ||= [] attributes['participants'] end |