class Messenger::Bot::Transmitter
Public Class Methods
new(sender)
click to toggle source
# File lib/messenger/bot/transmitter.rb, line 4 def initialize(sender) @sender_id = sender end
Public Instance Methods
action(sender_action=true)
click to toggle source
# File lib/messenger/bot/transmitter.rb, line 18 def action(sender_action=true) data = init_data.merge({ sender_action: sender_action ? "typing_on" : "typing_off" }) Messenger::Bot::Request.post("https://graph.facebook.com/v2.6/me/messages?access_token=#{Messenger::Bot::Config.access_token}", data) end
get_profile(fields=nil)
click to toggle source
# File lib/messenger/bot/transmitter.rb, line 13 def get_profile(fields=nil) fields ||= [:locale, :timezone, :gender, :first_name, :last_name, :profile_pic] Messenger::Bot::Request.get("https://graph.facebook.com/v2.6/#{@sender_id}?fields=#{fields.join(",")}&access_token=#{Messenger::Bot::Config.access_token}") end
reply(data)
click to toggle source
# File lib/messenger/bot/transmitter.rb, line 8 def reply(data) data = init_data.merge({ message: data }) Messenger::Bot::Request.post("https://graph.facebook.com/v2.6/me/messages?access_token=#{Messenger::Bot::Config.access_token}", data) end
Private Instance Methods
init_data()
click to toggle source
# File lib/messenger/bot/transmitter.rb, line 25 def init_data { recipient: { id: @sender_id } } end