Class: MessengerPlatform::TextMessage

Inherits:
MessageBase show all
Defined in:
lib/messenger_platform/text_message.rb

Constant Summary collapse

MAX_MESSAGE_LENGTH =
320

Instance Attribute Summary collapse

Attributes inherited from MessageBase

#notification_type, #recipient

Instance Method Summary collapse

Methods inherited from MessageBase

#deliver

Constructor Details

#initialize(recipient, message, notification_type = :regular) ⇒ TextMessage

Returns a new instance of TextMessage.



7
8
9
10
# File 'lib/messenger_platform/text_message.rb', line 7

def initialize(recipient, message, notification_type = :regular)
  super(recipient, notification_type)
  @message = message.slice(0, MAX_MESSAGE_LENGTH)
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/messenger_platform/text_message.rb', line 5

def message
  @message
end

Instance Method Details

#serializeObject



12
13
14
15
16
17
18
# File 'lib/messenger_platform/text_message.rb', line 12

def serialize
  super.merge({
    message: {
      text: message
    }
  })
end