Class: Chatbase::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/chatbase/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent_key: nil) ⇒ Message

Returns a new instance of Message.



5
6
7
8
# File 'lib/chatbase/message.rb', line 5

def initialize(agent_key: nil)
  @agent_key = agent_key || Chatbase.agent_key
  @http_service = HttpService.new
end

Instance Attribute Details

#agent_keyObject

Returns the value of attribute agent_key.



3
4
5
# File 'lib/chatbase/message.rb', line 3

def agent_key
  @agent_key
end

Instance Method Details

#http_serviceObject



10
11
12
# File 'lib/chatbase/message.rb', line 10

def http_service
  @http_service
end

#send_fbmessage(request_parameters) ⇒ Object



18
19
20
# File 'lib/chatbase/message.rb', line 18

def send_fbmessage(request_parameters)
  http_service.request_post("/api/facebook/message_received?api_key=#{@agent_key}", request_parameters)
end

#send_message(request_parameters) ⇒ Object



14
15
16
# File 'lib/chatbase/message.rb', line 14

def send_message(request_parameters)
  http_service.request_post("/api/message", {'api_key': @agent_key}.merge(request_parameters))
end