class UI::FBCarousel
GENERIC TEMPLATE (aka CAROUSEL) #######################
developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template
Public Class Methods
new(elements)
click to toggle source
# File lib/ui/fb_carousel.rb, line 8 def initialize(elements) @template = { recipient: { id: nil }, message: { attachment: { type: 'template', payload: { template_type: 'generic', image_aspect_ratio: 'horizontal', elements: parse_elements(elements) } } } } end
Public Instance Methods
horizontal_images()
click to toggle source
set image aspect ratio to 'horizontal'
# File lib/ui/fb_carousel.rb, line 31 def horizontal_images self.image_aspect_ratio = 'horizontal' self end
square_images()
click to toggle source
set image aspect ratio to 'square'
# File lib/ui/fb_carousel.rb, line 25 def square_images self.image_aspect_ratio = 'square' self end
Private Instance Methods
image_aspect_ratio=(type)
click to toggle source
# File lib/ui/fb_carousel.rb, line 38 def image_aspect_ratio=(type) @template[:message][:attachment][:payload][:image_aspect_ratio] = type end
parse_elements(elements)
click to toggle source
# File lib/ui/fb_carousel.rb, line 42 def parse_elements(elements) elements = [elements] if elements.class == Hash elements.map do |elt| elt[:buttons] = parse_buttons(elt[:buttons]) elt end end