Class: MessengerPlatform::MessageBase

Inherits:
Object
  • Object
show all
Defined in:
lib/messenger_platform/message_base.rb

Direct Known Subclasses

TextMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipient, notification_type = :regular) ⇒ MessageBase

Returns a new instance of MessageBase.



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

def initialize(recipient, notification_type = :regular)
  @recipient = recipient
  @notification_type = notification_type
end

Instance Attribute Details

#notification_typeObject (readonly)

Returns the value of attribute notification_type.



3
4
5
# File 'lib/messenger_platform/message_base.rb', line 3

def notification_type
  @notification_type
end

#recipientObject (readonly)

Returns the value of attribute recipient.



3
4
5
# File 'lib/messenger_platform/message_base.rb', line 3

def recipient
  @recipient
end

Instance Method Details

#deliverObject



17
18
19
# File 'lib/messenger_platform/message_base.rb', line 17

def deliver
  MessengerPlatform::MessageSender.deliver(self)
end

#serializeObject



10
11
12
13
14
15
# File 'lib/messenger_platform/message_base.rb', line 10

def serialize
  {
    recipient: recipient.serialize,
    notification_type: notification_type.to_s.upcase
  }
end