class MotionAI::Client

Constants

API_ENDPOINT
GET_CONVERSATIONS_API_PATH
MESSAGE_BOT_API_PATH

Attributes

bot_id[RW]

Public Class Methods

new(api_key, bot_id) click to toggle source
# File lib/motion-ai/client.rb, line 14
def initialize(api_key, bot_id)
  @api_key = api_key
  @bot_id = bot_id
  @http = Faraday.new(url: API_ENDPOINT) do |conn|
    conn.response :json, content_type: /\bjson$/
    conn.adapter Faraday.default_adapter
  end
end

Public Instance Methods

get_conversations(params = {}) click to toggle source
# File lib/motion-ai/client.rb, line 37
def get_conversations(params = {})
  params[:key] = @api_key

  required = [:key]
  required.each do |param|
    unless params.key? param
      raise "Required param #{param} not present"
    end
  end

  @http.get URI.join(API_ENDPOINT, GET_CONVERSATIONS_API_PATH), params
end
message_bot(params = {}) click to toggle source
# File lib/motion-ai/client.rb, line 23
def message_bot(params = {})
  params[:key] = @api_key
  params[:bot] = @bot_id

  required = [:bot, :msg, :session, :key]
  required.each do |param|
    unless params.key? param
      raise "Required param #{param} not present"
    end
  end

  @http.get URI.join(API_ENDPOINT, MESSAGE_BOT_API_PATH), params
end