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:, text: nil, attachments: nil) ⇒ Message

Returns a new instance of Message.



8
9
10
11
12
13
# File 'lib/messenger/parameters/message.rb', line 8

def initialize(mid:, seq:, text: nil, attachments: nil)
  @mid         = mid
  @seq         = seq
  @text        = text if text.present?
  @attachments = build_attachments(attachments) if attachments.present?
end

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



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

def attachments
  @attachments
end

#midObject

Returns the value of attribute mid.



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

def mid
  @mid
end

#seqObject

Returns the value of attribute seq.



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

def seq
  @seq
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



15
16
17
# File 'lib/messenger/parameters/message.rb', line 15

def build_attachments(attachments)
  attachments.map { |attachment| Attachment.new(attachment.symbolize_keys) }
end