mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
Hash: select entries by keys
This commit is contained in:
parent
c23075fa19
commit
c58b4fb2e9
11 changed files with 201 additions and 141 deletions
|
@ -1,8 +1,7 @@
|
|||
module Deserializers
|
||||
module Xml
|
||||
class Domain
|
||||
attr_reader :frame
|
||||
attr_reader :registrar
|
||||
attr_reader :frame, :registrar
|
||||
|
||||
def initialize(frame, registrar)
|
||||
@frame = frame
|
||||
|
@ -15,15 +14,24 @@ module Deserializers
|
|||
registrar_id: registrar,
|
||||
registrant_id: if_present('registrant'),
|
||||
reserved_pw: if_present('reserved > pw'),
|
||||
period: frame.css('period').text.present? ? Integer(frame.css('period').text) : 1,
|
||||
period_unit: frame.css('period').first ? frame.css('period').first[:unit] : 'y',
|
||||
}
|
||||
|
||||
attributes.merge!(assign_period_attributes)
|
||||
|
||||
pw = frame.css('authInfo > pw').text
|
||||
attributes[:transfer_code] = pw if pw.present?
|
||||
attributes.compact
|
||||
end
|
||||
|
||||
def assign_period_attributes
|
||||
period = frame.css('period')
|
||||
|
||||
{
|
||||
period: period.text.present? ? Integer(period.text) : 1,
|
||||
period_unit: period.first ? period.first[:unit] : 'y',
|
||||
}
|
||||
end
|
||||
|
||||
def if_present(css_path)
|
||||
return if frame.css(css_path).blank?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue