Class: Bushido::DataController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/bushido/data_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

POST /bushido/data/



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/bushido/data_controller.rb', line 5

def index
  @key = params.delete("key")
  if ENV["BUSHIDO_APP_KEY"] != @key
    respond_to do |format|
      format.html { render :layout => false, :text => true, :status => :forbidden }
      format.json { render :status => 401 }
      return
    end
  end
  
  puts "Bushibus Data rec'd"
  puts params.inspect
  puts params["category"].inspect

  hook_data             = {}
  hook_data["category"] = params["category"]
  hook_data["event"]    = params["event"]
  hook_data["data"]     = params["data"]

  puts "Firing with: #{hook_data.inspect}"
  event = "#{params['category']}.#{params['event']}".gsub('.', '_').to_sym

  Bushido::Data.fire(hook_data, event)

  respond_to do |format|
    format.json {render :json => {'acknowledged' => true}, :status => 200}
  end
end