internetee-registry/app/controllers/api/v1/registrant/registry_locks_controller.rb
Maciej Szlosarczyk 9623e2fb97
Refactor RegistrantUser class
* Extract frequently used country_code and ident methods
* Refactor domain query
* Add contact query method
* Add adminstrated_domains query method. Name will most likely change
  in the future developments
* Change registry locks integration test name
2018-08-23 16:00:44 +03:00

38 lines
1,008 B
Ruby

module Api
module V1
module Registrant
class RegistryLocksController < BaseController
before_action :set_domain
def create
if @domain.apply_registry_lock
render json: @domain
else
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
status: :unprocessable_entity
end
end
def destroy
if @domain.remove_registry_lock
render json: @domain
else
render json: { errors: [{ base: ['Domain is not locked'] }] },
status: :unprocessable_entity
end
end
private
def set_domain
domain_pool = current_user.administrated_domains
@domain = domain_pool.find_by(uuid: params[:domain_uuid])
return if @domain
render json: { errors: [{ base: ['Domain not found'] }] },
status: :not_found and return
end
end
end
end
end