mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor
This commit is contained in:
parent
c838e0f574
commit
b6e61f5bda
3 changed files with 11 additions and 25 deletions
|
@ -36,12 +36,12 @@ module Epp::Common
|
||||||
obj.errors.each do |key, msg|
|
obj.errors.each do |key, msg|
|
||||||
if msg.is_a?(Hash)
|
if msg.is_a?(Hash)
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: find_code(msg[:msg]),
|
code: find_code(error_code_map, msg[:msg]),
|
||||||
msg: msg[:msg],
|
msg: msg[:msg],
|
||||||
value: {obj: msg[:obj], val: msg[:val]},
|
value: {obj: msg[:obj], val: msg[:val]},
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
next unless code = find_code(msg)
|
next unless code = find_code(error_code_map, msg)
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: code,
|
code: code,
|
||||||
msg: msg
|
msg: msg
|
||||||
|
@ -50,7 +50,7 @@ module Epp::Common
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_code(msg)
|
def find_code(error_code_map, msg)
|
||||||
error_code_map.each do |code, values|
|
error_code_map.each do |code, values|
|
||||||
return code if values.include?(msg)
|
return code if values.include?(msg)
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,11 +102,8 @@ module Epp::ContactsHelper
|
||||||
|
|
||||||
def handle_contact_errors # handle_errors conflicted with domain logic
|
def handle_contact_errors # handle_errors conflicted with domain logic
|
||||||
handle_epp_errors({
|
handle_epp_errors({
|
||||||
'2302' => [:epp_id_taken],
|
'2302' => ['Contact id already exists'],
|
||||||
'2303' => [:not_found, :epp_obj_does_not_exist]
|
'2303' => [:not_found, :epp_obj_does_not_exist]
|
||||||
}, @contact
|
},@contact)
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,21 +60,10 @@ module Epp::DomainsHelper
|
||||||
|
|
||||||
def handle_errors
|
def handle_errors
|
||||||
handle_epp_errors({
|
handle_epp_errors({
|
||||||
'2302' => [:epp_domain_taken, :reserved],
|
|
||||||
'2306' => [:blank, [:out_of_range, {min: 1, max: 13}]],
|
|
||||||
'2303' => [:not_found],
|
|
||||||
'2005' => [:hostname_invalid, :ip_invalid]
|
|
||||||
}, @domain
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def error_code_map
|
|
||||||
{
|
|
||||||
'2302' => ['Domain name already exists', 'Domain name is reserved or restricted'],
|
'2302' => ['Domain name already exists', 'Domain name is reserved or restricted'],
|
||||||
'2306' => ['Registrant is missing', 'Nameservers count must be between 1-13', 'Admin contact is missing'],
|
'2306' => ['Registrant is missing', 'Nameservers count must be between 1-13', 'Admin contact is missing'],
|
||||||
'2303' => ['Contact was not found'],
|
'2303' => ['Contact was not found'],
|
||||||
'2005' => ['Hostname is invalid', 'IP is invalid']
|
'2005' => ['Hostname is invalid', 'IP is invalid']
|
||||||
}
|
}, @domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue