ars apis
This commit is contained in:
parent
08e1c5274d
commit
8f0b8929ba
|
|
@ -2,6 +2,42 @@ class ArsesController < ApplicationController
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
|
def index
|
||||||
|
if params[:code] != Rails.application.config.data_dump_code
|
||||||
|
render :json => {error: "Unauthorized"}, :status => 401
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@arses = Ars.all
|
||||||
|
render :json => @arses
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if params[:code] != Rails.application.config.data_dump_code
|
||||||
|
render :json => {error: "Unauthorized"}, :status => 401
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@ars = Ars.find_by_id(params[:id])
|
||||||
|
if @ars.nil?
|
||||||
|
render :json => {error: "Not Found"}, :status => 404
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
allowed = [:password, :username, :active, :beta, :name, :provider, :id_int, :ip, :port, :continent, :country, :city, :subdivision, :latitude, :longitude]
|
||||||
|
|
||||||
|
update_hash = {}
|
||||||
|
allowed.each do |attr|
|
||||||
|
update_hash[attr] = params[attr] if params.has_key?(attr)
|
||||||
|
end
|
||||||
|
|
||||||
|
if @ars.update_attributes(update_hash, as: :admin)
|
||||||
|
render :json => @ars, :status => :ok
|
||||||
|
else
|
||||||
|
render :json => @ars.errors, :status => :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# create or update a client_artifact row
|
# create or update a client_artifact row
|
||||||
def get_or_create
|
def get_or_create
|
||||||
name = params[:name]
|
name = params[:name]
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ JamAdmin::Application.routes.draw do
|
||||||
match '/api/jam_tracks/released' => 'jam_track#dump_released', :via => :get, as: 'released_jamtracks_csv'
|
match '/api/jam_tracks/released' => 'jam_track#dump_released', :via => :get, as: 'released_jamtracks_csv'
|
||||||
|
|
||||||
match '/api/arses/register' => 'arses#get_or_create', :via => :post
|
match '/api/arses/register' => 'arses#get_or_create', :via => :post
|
||||||
|
match '/api/arses' => 'arses#index', :via => :get
|
||||||
|
match '/api/arses/:id' => 'arses#update', :via => :post
|
||||||
|
|
||||||
mount Resque::Server.new, :at => "/resque"
|
mount Resque::Server.new, :at => "/resque"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue