mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
invalid csv file should return empty array of domains
This commit is contained in:
parent
28b7acfc96
commit
eb31c9f609
2 changed files with 11 additions and 38 deletions
|
@ -10,20 +10,17 @@ class Registrar
|
|||
|
||||
return csv_list_empty_guard if domains == []
|
||||
|
||||
# uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
|
||||
# request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
|
||||
# request.body = { data: { type: 'nameserver', id: params[:old_hostname],
|
||||
# domains: domains || [],
|
||||
# attributes: { hostname: params[:new_hostname],
|
||||
# ipv4: ipv4,
|
||||
# ipv6: ipv6 } } }.to_json
|
||||
# request.basic_auth(current_registrar_user.username,
|
||||
# current_registrar_user.plain_text_password)
|
||||
uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
|
||||
request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
|
||||
request.body = { data: { type: 'nameserver', id: params[:old_hostname],
|
||||
domains: domains || [],
|
||||
attributes: { hostname: params[:new_hostname],
|
||||
ipv4: ipv4,
|
||||
ipv6: ipv6 } } }.to_json
|
||||
request.basic_auth(current_registrar_user.username,
|
||||
current_registrar_user.plain_text_password)
|
||||
|
||||
# response = do_request(request, uri)
|
||||
|
||||
response = Actions::NameserverBulkChange.new(domains, params)
|
||||
response.call
|
||||
response = do_request(request, uri)
|
||||
|
||||
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
@ -54,7 +51,7 @@ class Registrar
|
|||
end
|
||||
|
||||
def domain_list_from_csv
|
||||
return [] if params[:puny_file].blank?
|
||||
return if params[:puny_file].blank?
|
||||
|
||||
domains = []
|
||||
csv = CSV.read(params[:puny_file].path, headers: true)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
module Actions
|
||||
class NameserverBulkChange
|
||||
def initialize(domains, params, ipv4, ipv6)
|
||||
@domains = domains
|
||||
@params = params
|
||||
@ipv4 = ipv4
|
||||
@ipv6 = ipv6
|
||||
end
|
||||
|
||||
def call
|
||||
uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
|
||||
request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
|
||||
request.body = { data: { type: 'nameserver', id: @params[:old_hostname],
|
||||
domains: @domains || [],
|
||||
attributes: { hostname: @params[:new_hostname],
|
||||
ipv4: ipv4,
|
||||
ipv6: ipv6 } } }.to_json
|
||||
request.basic_auth(current_registrar_user.username,
|
||||
current_registrar_user.plain_text_password)
|
||||
|
||||
response = do_request(request, uri)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue