Class: MessageQuickly::Messaging::GenericTemplateAttachment

Inherits:
TemplateAttachment show all
Defined in:
lib/message_quickly/messaging/generic_template_attachment.rb

Instance Attribute Summary collapse

Attributes inherited from TemplateAttachment

#template_type

Attributes inherited from Attachment

#payload, #type

Instance Method Summary collapse

Methods inherited from Attachment

#file?

Constructor Details

#initialize(params = {}) ⇒ GenericTemplateAttachment

Returns a new instance of GenericTemplateAttachment.



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

def initialize(params = {})
  self.elements ||= []
  params['template_type'] ||= 'generic'
  super(params)
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



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

def elements
  @elements
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#build_elementObject



13
14
15
# File 'lib/message_quickly/messaging/generic_template_attachment.rb', line 13

def build_element
  elements << Element.new.tap { |element| yield element }
end

#to_hashObject



17
18
19
20
21
22
23
24
25
# File 'lib/message_quickly/messaging/generic_template_attachment.rb', line 17

def to_hash
  {
    type: type,
    payload: {
      template_type: template_type,
      elements: elements.collect { |element| element.to_hash }
    }
  }
end