Class: Messenger::Parameters::Message

Inherits:
Object
  • Object
show all
Includes:
Callback
Defined in:
lib/messenger/parameters/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callback

#type

Constructor Details

#initialize(mid:, seq:, sticker_id: nil, text: nil, attachments: nil, quick_reply: nil, is_echo: nil, app_id: nil, metadata: nil) ⇒ Message

Returns a new instance of Message.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/messenger/parameters/message.rb', line 8

def initialize(mid:, seq:, sticker_id: nil, text: nil, attachments: nil, quick_reply: nil, is_echo: nil, app_id: nil, metadata: nil)
  @mid         = mid
  @seq         = seq
  @sticker_id  = sticker_id if sticker_id.present?
  @text        = text if text.present?
  @attachments = build_attachments(attachments) if attachments.present?
  @quick_reply = build_quick_reply(quick_reply) if quick_reply.present?
  @is_echo     = is_echo
  @app_id      = app_id
  @metadata    = 
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def app_id
  @app_id
end

#attachmentsObject

Returns the value of attribute attachments.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def attachments
  @attachments
end

#is_echoObject

Returns the value of attribute is_echo.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def is_echo
  @is_echo
end

#metadataObject

Returns the value of attribute metadata.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def 
  @metadata
end

#midObject

Returns the value of attribute mid.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def mid
  @mid
end

#quick_replyObject

Returns the value of attribute quick_reply.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def quick_reply
  @quick_reply
end

#seqObject

Returns the value of attribute seq.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def seq
  @seq
end

#sticker_idObject

Returns the value of attribute sticker_id.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def sticker_id
  @sticker_id
end

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/messenger/parameters/message.rb', line 6

def text
  @text
end

Instance Method Details

#build_attachments(attachments) ⇒ Object



20
21
22
# File 'lib/messenger/parameters/message.rb', line 20

def build_attachments(attachments)
  attachments.map { |attachment| Attachment.new(attachment.transform_keys(&:to_sym).slice(:type, :payload)) }
end

#build_quick_reply(quick_reply) ⇒ Object



24
25
26
# File 'lib/messenger/parameters/message.rb', line 24

def build_quick_reply(quick_reply)
  QuickReply.new(quick_reply.transform_keys(&:to_sym))
end