Add helper for extracting epp attributes

This commit is contained in:
Martin Lensment 2015-02-16 13:05:09 +02:00
parent 27d19ad237
commit 16ca5eb44c
2 changed files with 65 additions and 6 deletions

30
lib/epp_parser.rb Normal file
View file

@ -0,0 +1,30 @@
module EppParser
def domain_rem_params
{
nameservers_attributes: to_destroy
}
end
def nameservers_attributes
ns_list = Epp::EppDomain.parse_nameservers_from_frame(params[:parsed_frame])
to_destroy = []
ns_list.each do |ns_attrs|
nameserver = @domain.nameservers.where(ns_attrs).try(:first)
if nameserver.blank?
epp_errors << {
code: '2303',
msg: I18n.t('nameserver_not_found'),
value: { obj: 'hostAttr', val: ns_attrs[:hostname] }
}
else
to_destroy << {
id: nameserver.id,
_destroy: 1
}
end
end
end
end