Class: MessageQuickly::Messaging::Message
- Inherits:
-
Object
- Object
- MessageQuickly::Messaging::Message
- Defined in:
- lib/message_quickly/messaging/message.rb
Instance Attribute Summary collapse
-
#attachment ⇒ Object
Returns the value of attribute attachment.
-
#quick_replies ⇒ Object
Returns the value of attribute quick_replies.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #build_attachment(attachment_type) {|attachment| ... } ⇒ Object
- #build_quick_reply {|new_quick_reply| ... } ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Message
constructor
A new instance of Message.
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Message
Returns a new instance of Message.
7 8 9 10 |
# File 'lib/message_quickly/messaging/message.rb', line 7 def initialize( = {}) .each { |key, value| instance_variable_set("@#{key}", value) } yield self if block_given? end |
Instance Attribute Details
#attachment ⇒ Object
Returns the value of attribute attachment.
5 6 7 |
# File 'lib/message_quickly/messaging/message.rb', line 5 def end |
#quick_replies ⇒ Object
Returns the value of attribute quick_replies.
5 6 7 |
# File 'lib/message_quickly/messaging/message.rb', line 5 def quick_replies @quick_replies end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/message_quickly/messaging/message.rb', line 5 def text @text end |
Instance Method Details
#build_attachment(attachment_type) {|attachment| ... } ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/message_quickly/messaging/message.rb', line 12 def () case when :image self. = MessageQuickly::Messaging::ImageAttachment.new when :audio self. = MessageQuickly::Messaging::AudioAttachment.new when :video self. = MessageQuickly::Messaging::VideoAttachment.new when :generic_template self. = MessageQuickly::Messaging::GenericTemplateAttachment.new when :button_template self. = MessageQuickly::Messaging::ButtonTemplateAttachment.new when :receipt_template self. = MessageQuickly::Messaging::ReceiptTemplateAttachment.new end yield if block_given? end |
#build_quick_reply {|new_quick_reply| ... } ⇒ Object
30 31 32 33 34 35 |
# File 'lib/message_quickly/messaging/message.rb', line 30 def build_quick_reply @quick_replies ||= [] new_quick_reply = MessageQuickly::Messaging::QuickReply.new quick_replies << new_quick_reply yield new_quick_reply end |
#to_hash ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/message_quickly/messaging/message.rb', line 37 def to_hash if hash_buffer = { attachment: .to_hash } else hash_buffer = { text: text } end hash_buffer.merge!({ quick_replies: quick_replies.collect { |quick_reply| quick_reply.to_hash } }) if quick_replies.present? hash_buffer end |