mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Implement partial domain deserializer
This commit is contained in:
parent
7459d7e0c5
commit
b683fe813c
2 changed files with 76 additions and 0 deletions
49
lib/deserializers/xml/domain.rb
Normal file
49
lib/deserializers/xml/domain.rb
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
module Deserializers
|
||||||
|
module Xml
|
||||||
|
class Domain
|
||||||
|
attr_reader :frame
|
||||||
|
|
||||||
|
def initialize(frame)
|
||||||
|
@frame = frame
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
attributes = {
|
||||||
|
name: if_present('name'),
|
||||||
|
registrar_id: current_user.registrar.id,
|
||||||
|
reserved_pw: if_present('reserved > pw'),
|
||||||
|
period: Integer(frame.css('period').text, 1),
|
||||||
|
period_unit: parsed_frame.css('period').first ? parsed_frame.css('period').first[:unit] : 'y'
|
||||||
|
}
|
||||||
|
|
||||||
|
pw = frame.css('authInfo > pw').text
|
||||||
|
attributes[:transfer_code] = pw if pw.present?
|
||||||
|
attributes.compact
|
||||||
|
end
|
||||||
|
|
||||||
|
def if_present(css_path)
|
||||||
|
return if frame.css(css_path).blank?
|
||||||
|
|
||||||
|
frame.css(css_path).text
|
||||||
|
end
|
||||||
|
|
||||||
|
def statuses_to_add
|
||||||
|
statuses_frame = frame.css('add')
|
||||||
|
return if statuses_frame.blank?
|
||||||
|
|
||||||
|
statuses_frame.css('status').map do |status|
|
||||||
|
status['s']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def statuses_to_remove
|
||||||
|
statuses_frame = frame.css('rem')
|
||||||
|
return if statuses_frame.blank?
|
||||||
|
|
||||||
|
statuses_frame.css('status').map do |status|
|
||||||
|
status['s']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
27
lib/deserializers/xml/domain_create.rb
Normal file
27
lib/deserializers/xml/domain_create.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
require 'deserializers/xml/legal_document'
|
||||||
|
require 'deserializers/xml/ident'
|
||||||
|
require 'deserializers/xml/contact'
|
||||||
|
|
||||||
|
module Deserializers
|
||||||
|
module Xml
|
||||||
|
class ContactUpdate
|
||||||
|
attr_reader :frame
|
||||||
|
|
||||||
|
def initialize(frame)
|
||||||
|
@frame = frame
|
||||||
|
end
|
||||||
|
|
||||||
|
def contact
|
||||||
|
@contact ||= ::Deserializers::Xml::Contact.new(frame).call
|
||||||
|
end
|
||||||
|
|
||||||
|
def ident
|
||||||
|
@ident ||= ::Deserializers::Xml::Ident.new(frame).call
|
||||||
|
end
|
||||||
|
|
||||||
|
def legal_document
|
||||||
|
@legal_document ||= ::Deserializers::Xml::LegalDocument.new(frame).call
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue