Class: Layer::Message
- Extended by:
- Operations::Delete::ClassMethods, Operations::Destroy::ClassMethods, Operations::Find::ClassMethods
- Includes:
- Operations::Delete, Operations::Destroy, Operations::Find
- Defined in:
- lib/layer/message.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
-
#conversation ⇒ Layer::Conversation
Returns the conversation this message belongs to.
-
#delivered! ⇒ Object
Marks the message as delivered to the current user.
-
#read! ⇒ Object
Marks the message as read by the current user.
-
#receipts_url ⇒ String
The endpoint to send read and delivered receipts to.
-
#sent_at ⇒ Time
Returns the time the message was sent at.
Methods included from Operations::Find::ClassMethods
Methods included from Operations::Delete::ClassMethods
Methods included from Operations::Destroy::ClassMethods
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
#conversation ⇒ Layer::Conversation
Returns the conversation this message belongs to
23 24 25 |
# File 'lib/layer/message.rb', line 23 def conversation Conversation.from_response(attributes['conversation'], client) end |
#delivered! ⇒ Object
This is only available via the REST API.
Marks the message as delivered to the current user
43 44 45 |
# File 'lib/layer/message.rb', line 43 def delivered! client.post(receipts_url, { type: 'delivery' }) end |
#read! ⇒ Object
This is only available via the REST API.
Marks the message as read by the current user
37 38 39 |
# File 'lib/layer/message.rb', line 37 def read! client.post(receipts_url, { type: 'read' }) end |
#receipts_url ⇒ String
This is only available via the REST API.
The endpoint to send read and delivered receipts to
51 52 53 |
# File 'lib/layer/message.rb', line 51 def receipts_url attributes['receipts_url'] || "#{url}/receipts" end |
#sent_at ⇒ Time
Returns the time the message was sent at
30 31 32 |
# File 'lib/layer/message.rb', line 30 def sent_at Time.parse(attributes['sent_at']) end |