Class: Fb::Messenger::Template::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/fb/messenger/templates/generic.rb

Overview

generic template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Generic

Returns a new instance of Generic.



8
9
10
# File 'lib/fb/messenger/templates/generic.rb', line 8

def initialize(opts = {})
  @generic_items = opts[:generic_items] || []
end

Instance Attribute Details

#generic_itemsObject

Returns the value of attribute generic_items.



6
7
8
# File 'lib/fb/messenger/templates/generic.rb', line 6

def generic_items
  @generic_items
end

Instance Method Details

#templateObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fb/messenger/templates/generic.rb', line 12

def template
  {
    attachment: {
      type: 'template',
      payload: {
        template_type: 'generic',
        elements: generic_items.map(&:template)
      }
    }
  }
end