class Layer::Message
@example Sending messages
conversation = Layer::Conversation.find('CONVERSATION_ID_HERE') conversation.messages.create({ sender: { name: 'Server' }, parts: [{ body: 'Hello!', mime_type: 'text/plain' }]})
@see developer.layer.com/docs/platform#send-a-message Layer
Platform API Documentation about messages @see developer.layer.com/docs/client/rest#messages Layer
REST API Documentation about messages @see Layer::Content
Sending rich content using Layer::Content
@!macro various-apis
Public Instance Methods
conversation()
click to toggle source
Returns the conversation this message belongs to
@return [Layer::Conversation] the message's conversation
# File lib/layer/message.rb, line 23 def conversation Conversation.from_response(attributes['conversation'], client) end
delivered!()
click to toggle source
Marks the message as delivered to the current user @!macro rest-api
# File lib/layer/message.rb, line 43 def delivered! client.post(receipts_url, { type: 'delivery' }) end
read!()
click to toggle source
Marks the message as read by the current user
@!macro rest-api
# File lib/layer/message.rb, line 37 def read! client.post(receipts_url, { type: 'read' }) end
receipts_url()
click to toggle source
The endpoint to send read and delivered receipts to
@return [String] the url of the endpoint @!macro rest-api
# File lib/layer/message.rb, line 51 def receipts_url attributes['receipts_url'] || "#{url}/receipts" end
sent_at()
click to toggle source
Returns the time the message was sent at
@return [Time] the time the message was sent at
# File lib/layer/message.rb, line 30 def sent_at Time.parse(attributes['sent_at']) end