Class: EPP::Domain::Update

Inherits:
Command
  • Object
show all
Defined in:
lib/epp-client/domain/update.rb

Constant Summary collapse

ADD_REM_ORDER =
[:ns, :contact, :status]
CHG_ORDER =
[:registrant, :auth_info]

Instance Attribute Summary

Attributes inherited from Command

#namespaces

Instance Method Summary collapse

Methods inherited from Command

#set_namespaces

Methods included from XMLHelpers

#as_xml, #epp_namespace, #epp_node, #xml_document, #xml_namespace, #xml_node

Constructor Details

#initialize(name, options = {}) ⇒ Update

Returns a new instance of Update.

Parameters:

  • [Hash] (Hash)

    a customizable set of options



11
12
13
14
15
16
17
18
19
20
# File 'lib/epp-client/domain/update.rb', line 11

def initialize(name, options = {})
  @name = name
  @add  = options.delete(:add) || {}
  @rem  = options.delete(:rem) || {}
  @chg  = options.delete(:chg) || {}

  @add.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
  @rem.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
  @chg.delete_if { |k,_| !CHG_ORDER.include?(k) }
end

Instance Method Details

#nameObject



22
23
24
# File 'lib/epp-client/domain/update.rb', line 22

def name
  'update'
end

#to_xmlObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/epp-client/domain/update.rb', line 26

def to_xml
  node = super
  node << domain_node('name', @name)

  unless @add.empty?
    node << add = domain_node('add')
    add_rem_to_xml(add, @add)
  end

  unless @rem.empty?
    node << rem = domain_node('rem')
    add_rem_to_xml(rem, @rem)
  end

  unless @chg.empty?
    node << chg = domain_node('chg')
    CHG_ORDER.each do |key|
      value = @chg[key]
      next if value.nil?
      
      case key
      when :registrant
        chg << domain_node('registrant', value)
      when :auth_info
        chg << auth_info_to_xml(value)
      end
    end
  end
  
  node
end