Class: MessageQuickly::Messaging::Element

Inherits:
Base
  • Object
show all
Defined in:
lib/message_quickly/messaging/element.rb

Direct Known Subclasses

Receipt::Element

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Element

Returns a new instance of Element.



7
8
9
10
# File 'lib/message_quickly/messaging/element.rb', line 7

def initialize(params = {})
  self.buttons ||= []
  super(params)
end

Instance Attribute Details

#buttonsObject

Returns the value of attribute buttons.



5
6
7
# File 'lib/message_quickly/messaging/element.rb', line 5

def buttons
  @buttons
end

#image_urlObject

Returns the value of attribute image_url.



5
6
7
# File 'lib/message_quickly/messaging/element.rb', line 5

def image_url
  @image_url
end

#subtitleObject

Returns the value of attribute subtitle.



5
6
7
# File 'lib/message_quickly/messaging/element.rb', line 5

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/message_quickly/messaging/element.rb', line 5

def title
  @title
end

Instance Method Details

#build_button(button_type) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/message_quickly/messaging/element.rb', line 12

def build_button(button_type)
  case button_type
  when :web_url
    button = WebUrlButton.new
  when :postback
    button = PostbackButton.new
  when :account_link
    button = AccountLinkButton.new
  end
  buttons << button.tap { |button| yield button }
end

#to_hashObject



24
25
26
27
28
29
30
31
# File 'lib/message_quickly/messaging/element.rb', line 24

def to_hash
  {
    title: title,
    image_url: image_url,
    subtitle: subtitle,
    buttons: buttons.collect { |button| button.to_hash }
  }
end