mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 19:48:28 +02:00
Improve DomainUpdate logic
This commit is contained in:
parent
096289abcc
commit
766d843597
4 changed files with 165 additions and 126 deletions
|
@ -14,7 +14,8 @@ module Deserializers
|
|||
|
||||
def call
|
||||
obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts,
|
||||
auth_info: if_present('pw'), nameservers: nameservers, dns_keys: dns_keys }
|
||||
auth_info: if_present('authInfo > pw'), nameservers: nameservers, dns_keys: dns_keys,
|
||||
registrar_id: registrar, statuses: statuses, reserved_pw: if_present('reserved > pw') }
|
||||
|
||||
obj.reject { |_key, val| val.blank? }
|
||||
end
|
||||
|
@ -41,14 +42,14 @@ module Deserializers
|
|||
def nameservers
|
||||
nameservers = []
|
||||
frame.css('add > ns > hostAttr').each do |ns|
|
||||
nsrv = { nameserver: ns.css('hostName').text, host_addr: [], action: 'add' }
|
||||
ns.css('hostAddr').each { |ha| nsrv[:host_addr] << { proto: ha.attr('ip').to_s.downcase, addr: ha.text } }
|
||||
nsrv = Deserializers::Xml::Nameserver.new(ns).call
|
||||
nsrv[:action] = 'add'
|
||||
nameservers << nsrv
|
||||
end
|
||||
|
||||
frame.css('rem > ns > hostAttr').each do |ns|
|
||||
nsrv = { nameserver: ns.css('hostName').text, host_addr: [], action: 'rem' }
|
||||
ns.css('hostAddr').each { |ha| nsrv[:host_addr] << { proto: ha.attr('ip').to_s.downcase, addr: ha.text } }
|
||||
nsrv = Deserializers::Xml::Nameserver.new(ns).call
|
||||
nsrv[:action] = 'rem'
|
||||
nameservers << nsrv
|
||||
end
|
||||
|
||||
|
@ -66,6 +67,17 @@ module Deserializers
|
|||
added + removed
|
||||
end
|
||||
|
||||
def statuses
|
||||
return unless frame.css('status').present?
|
||||
|
||||
statuses = []
|
||||
|
||||
frame.css('add > status').each { |entry| statuses << { status: entry.attr('s').to_s, action: 'add' } }
|
||||
frame.css('rem > status').each { |entry| statuses << { status: entry.attr('s').to_s, action: 'rem' } }
|
||||
|
||||
statuses
|
||||
end
|
||||
|
||||
def if_present(css_path)
|
||||
return if frame.css(css_path).blank?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue