Class: MasterApiKey::ApiKeysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/master_api_key/api_keys_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /api_keys



10
11
12
13
14
15
16
17
# File 'app/controllers/master_api_key/api_keys_controller.rb', line 10

def create
  begin
    @api_key = ApiKey.create!(group:group_param)
    render json: { apiKey: @api_key, status: :created }
  rescue ActionController::ParameterMissing => e
    respond_with_error(e.message, :bad_request)
  end
end

#destroyObject

DELETE /api_keys/1



20
21
22
23
24
25
26
27
# File 'app/controllers/master_api_key/api_keys_controller.rb', line 20

def destroy
  begin
    ApiKey.delete_all(['id = ?', access_id_param])
    head :ok
  rescue ActionController::ParameterMissing => e
    respond_with_error(e.message, :bad_request)
  end
end

#destroy_by_access_tokenObject

DELETE /api_keys



30
31
32
33
34
35
36
37
38
# File 'app/controllers/master_api_key/api_keys_controller.rb', line 30

def destroy_by_access_token
  begin
    Rails.logger.warn "the api token is #{access_token_param}"
    ApiKey.delete_all(['api_token = ?', access_token_param])
    head :ok
  rescue ActionController::ParameterMissing => e
    respond_with_error(e.message, :bad_request)
  end
end