Fix domain period parsing on create/renew in registrar area

#475
This commit is contained in:
Artur Beljajev 2017-04-27 14:32:27 +03:00
parent 8733389f5d
commit 7cadf66920

View file

@ -54,10 +54,13 @@ module Depp
keys = Domain.create_dnskeys_hash(domain_params) keys = Domain.create_dnskeys_hash(domain_params)
dns_hash[:_anonymus] = keys if keys.any? dns_hash[:_anonymus] = keys if keys.any?
period = domain_params[:period].to_i.to_s
period_unit = domain_params[:period][-1].to_s
if domain_params[:nameservers_attributes].select { |key, value| value['hostname'].present? }.any? if domain_params[:nameservers_attributes].select { |key, value| value['hostname'].present? }.any?
xml = epp_xml.create({ xml = epp_xml.create({
name: { value: domain_params[:name] }, name: { value: domain_params[:name] },
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } }, period: { value: period, attrs: { unit: period_unit } },
ns: Domain.create_nameservers_hash(domain_params), ns: Domain.create_nameservers_hash(domain_params),
registrant: { value: domain_params[:registrant] }, registrant: { value: domain_params[:registrant] },
_anonymus: Domain.create_contacts_hash(domain_params) _anonymus: Domain.create_contacts_hash(domain_params)
@ -65,7 +68,7 @@ module Depp
else else
xml = epp_xml.create({ xml = epp_xml.create({
name: { value: domain_params[:name] }, name: { value: domain_params[:name] },
period: { value: domain_params[:period].to_s[0], attrs: { unit: domain_params[:period].to_s[1] } }, period: { value: period, attrs: { unit: period_unit } },
registrant: { value: domain_params[:registrant] }, registrant: { value: domain_params[:registrant] },
_anonymus: Domain.create_contacts_hash(domain_params) _anonymus: Domain.create_contacts_hash(domain_params)
}, dns_hash, Domain.construct_custom_params_hash(domain_params)) }, dns_hash, Domain.construct_custom_params_hash(domain_params))
@ -97,10 +100,13 @@ module Depp
end end
def renew(params) def renew(params)
period = params[:period].to_i.to_s
period_unit = params[:period][-1].to_s
current_user.request(epp_xml.renew( current_user.request(epp_xml.renew(
name: { value: params[:domain_name] }, name: { value: params[:domain_name] },
curExpDate: { value: params[:cur_exp_date] }, curExpDate: { value: params[:cur_exp_date] },
period: { value: params[:period].to_s[0], attrs: { unit: params[:period].to_s[1] } } period: { value: period, attrs: { unit: period_unit } }
)) ))
end end