mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
Refactored xml_console_controller
This commit is contained in:
parent
30d7fcb26d
commit
48616ec3cd
1 changed files with 14 additions and 19 deletions
|
@ -7,12 +7,14 @@ module Repp
|
|||
THROTTLED_ACTIONS = %i[load_xml].freeze
|
||||
include Shunter::Integration::Throttle
|
||||
|
||||
PREFS = %w[
|
||||
domain-ee
|
||||
contact-ee
|
||||
eis
|
||||
epp-ee
|
||||
].freeze
|
||||
PREFS = %w[domain-ee contact-ee eis epp-ee].freeze
|
||||
|
||||
SCHEMA_VERSIONS = {
|
||||
'epp-ee' => '1.0',
|
||||
'eis' => '1.0',
|
||||
'contact-ee' => '1.1',
|
||||
'default' => '1.2',
|
||||
}.freeze
|
||||
|
||||
def load_xml
|
||||
cl_trid = "#{current_user.username}-#{Time.zone.now.to_i}"
|
||||
|
@ -37,23 +39,16 @@ module Repp
|
|||
end
|
||||
|
||||
def load_schema_by_prefix(pref, xml)
|
||||
case pref
|
||||
when 'epp-ee'
|
||||
insert_prefix_and_version(xml, pref, '1.0')
|
||||
when 'eis'
|
||||
insert_prefix_and_version(xml, pref, '1.0')
|
||||
when 'contact-ee'
|
||||
insert_prefix_and_version(xml, pref, '1.1')
|
||||
else
|
||||
insert_prefix_and_version(xml, pref, '1.2')
|
||||
end
|
||||
end
|
||||
|
||||
def insert_prefix_and_version(xml, pref, version)
|
||||
version = version_by_prefix(pref)
|
||||
xml.gsub!("\"#{pref}\"",
|
||||
"\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
|
||||
xml
|
||||
end
|
||||
|
||||
def version_by_prefix(pref)
|
||||
key = SCHEMA_VERSIONS.key?(pref) ? pref : 'default'
|
||||
SCHEMA_VERSIONS[key]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue