mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Remove code duplication
This commit is contained in:
parent
63837c40ba
commit
28304559fd
1 changed files with 7 additions and 4 deletions
|
@ -9,8 +9,7 @@ module Api
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if @domain.apply_registry_lock
|
if @domain.apply_registry_lock
|
||||||
serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
render json: serialized_domain(@domain)
|
||||||
render json: serializer.to_json
|
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
||||||
status: :unprocessable_entity
|
status: :unprocessable_entity
|
||||||
|
@ -19,8 +18,7 @@ module Api
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if @domain.remove_registry_lock
|
if @domain.remove_registry_lock
|
||||||
serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
render json: serialized_domain(@domain)
|
||||||
render json: serializer.to_json
|
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain is not locked'] }] },
|
render json: { errors: [{ base: ['Domain is not locked'] }] },
|
||||||
status: :unprocessable_entity
|
status: :unprocessable_entity
|
||||||
|
@ -46,6 +44,11 @@ module Api
|
||||||
] },
|
] },
|
||||||
status: :unauthorized and return
|
status: :unauthorized and return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def serialized_domain(domain)
|
||||||
|
serializer = Serializers::RegistrantApi::Domain.new(domain)
|
||||||
|
serializer.to_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue