class Messenger::Request

Public Class Methods

new(component, recipient_id) click to toggle source
# File lib/messenger/request.rb, line 3
def initialize(component, recipient_id)
  @recipient_id = recipient_id
  @body = body
  create_request(component)
end

Public Instance Methods

add_element(element) click to toggle source
# File lib/messenger/request.rb, line 13
def add_element(element)
  @body.merge!({ message: element.build })
end
add_sender_action(action) click to toggle source
# File lib/messenger/request.rb, line 17
def add_sender_action(action)
  @body.merge!(action.build)
end
body() click to toggle source
# File lib/messenger/request.rb, line 21
def body
  {
    recipient: { id: @recipient_id }
  }
end
build() click to toggle source
# File lib/messenger/request.rb, line 9
def build
  return @body
end
create_request(component) click to toggle source
# File lib/messenger/request.rb, line 27
def create_request(component)
  if component.is_a? Elements::SenderAction
    add_sender_action(component)
  else
    add_element(component)
  end
end