Add nameservers REST API

#661
This commit is contained in:
Artur Beljajev 2018-02-01 01:35:32 +02:00
parent 3ef38768a5
commit a5eaae562a
4 changed files with 62 additions and 2 deletions

View file

@ -58,5 +58,6 @@ module Repp
mount Repp::ContactV1
mount Repp::AccountV1
mount Repp::DomainTransfersV1
mount Repp::NameserversV1
end
end

View file

@ -0,0 +1,30 @@
module Repp
class NameserversV1 < Grape::API
version 'v1', using: :path
resource :nameservers do
put '/' do
params do
requires :data, type: Hash do
requires :type, type: String, allow_blank: false
requires :id, type: String, allow_blank: false
requires :attributes, type: Hash do
requires :hostname, type: String, allow_blank: false
end
end
end
current_user.registrar.nameservers.where(hostname: params[:data][:id]).each do |nameserver|
nameserver.hostname = params[:data][:attributes][:hostname]
nameserver.ipv4 = params[:data][:attributes][:ipv4]
nameserver.ipv6 = params[:data][:attributes][:ipv6]
nameserver.save!
end
status 204
body false
@response = {}
end
end
end
end