Class: Bot::Adapter::Kik

Inherits:
Base
  • Object
show all
Defined in:
lib/bot/adapters/kik.rb

Constant Summary collapse

AUTH_URL =
"https://auth.kik.com/verification/v1/check"
MESSAGING_URL =
"https://engine.apikik.com/api/v1/message"

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Bot::Adapter::Base

Instance Method Details

#send_messages(messages) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bot/adapters/kik.rb', line 10

def send_messages(messages)
  Rails.logger.error "\n\n\nSending:\n"
  Rails.logger.error messages.to_json
  Rails.logger.error "\n\n\n"

  RestClient::Request.execute({
    method: :post,
    user: config[:bot_user],
    password: config[:bot_token],
    url: MESSAGING_URL,
    payload: { messages: messages }.to_json,
    headers: { content_type: :json }
  })
rescue Exception => e
  Rails.logger.error "\n\n\nError:\n"
  Rails.logger.error e.response
  Rails.logger.error "\n\n\n"
  raise e
end