diff --git a/app/controllers/api/v1/gathers_controller.rb b/app/controllers/api/v1/gathers_controller.rb new file mode 100644 index 0000000..2358749 --- /dev/null +++ b/app/controllers/api/v1/gathers_controller.rb @@ -0,0 +1,32 @@ +class Api::V1::GathersController < Api::V1::BaseController + + def create + # gather = createFromParams + # + # unless gather + # render json: { errors: ['Invalid Data']}, status: :bad_request + # return + # end + + render text: createFromParams.inspect + end + + private + + def createFromParams + @gan = params[:gather] + unless checkAuth + return nil + end + + Gather.transaction do + gather = Gather.create(category_id: 18, status: Gather::STATE_FINISHED, created_at: Time.zone.parse(@gan[:done][:time]) ) + + + end + end + + def checkAuth + params[:sign] == Digest::SHA2.hexdigest( @gan.to_json + ENV['APP_SECRET']) + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 0a21852..3272203 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,7 @@ Ensl::Application.routes.draw do resources :teams, only: [:show] resources :servers, only: [:index] resources :maps, only: [:index] + resources :gathers, only: [:create] end end