Class: NominetEPP::Domain::UpdateSecDNSExtension

Inherits:
RequestExtension show all
Defined in:
lib/nominet-epp/requests/domain/update.rb

Constant Summary collapse

NAMESPACE =
'urn:ietf:params:xml:ns:secDNS-1.1'

Instance Attribute Summary

Attributes inherited from RequestExtension

#namespaces

Instance Method Summary collapse

Methods inherited from RequestExtension

#schemaLocation, #schema_name, #set_namespaces, #x_namespace, #x_node, #x_schemaLocation, #xml_namespace, #xml_node

Constructor Details

#initialize(attributes) ⇒ UpdateSecDNSExtension

Returns a new instance of UpdateSecDNSExtension.

Raises:

  • (ArgumentError)


75
76
77
78
79
80
81
82
83
# File 'lib/nominet-epp/requests/domain/update.rb', line 75

def initialize(attributes)
  @add = Array(attributes[:add])
  @rem = Array(attributes[:rem])
  @chg = Array(attributes[:chg])

  raise ArgumentError, "must provide :add, :rem or :chg keys" if @add.empty? && @rem.empty? && @chg.empty?

  @namespaces = {}
end

Instance Method Details

#namespace_nameObject



88
89
90
# File 'lib/nominet-epp/requests/domain/update.rb', line 88

def namespace_name
  'secDNS'
end

#namespace_uriObject



85
86
87
# File 'lib/nominet-epp/requests/domain/update.rb', line 85

def namespace_uri
  NAMESPACE
end

#to_xmlObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/nominet-epp/requests/domain/update.rb', line 92

def to_xml
  node = x_node('update')
  x_schemaLocation(node)

  if @rem[0] == :all || @rem[0] == 'all'
    node << x_node('rem').tap do |n|
      n << x_node('all', 'true')
    end
  elsif !@rem.empty?
    node << x_node('rem').tap do |n|
      @rem.each do |ds|
        n << x_node('dsData').tap do |dsData|
          dsData << x_node('keyTag', ds[:key_tag].to_s)
          dsData << x_node('alg', ds[:alg].to_s)
          dsData << x_node('digestType', ds[:digest_type].to_s)
          dsData << x_node('digest', ds[:digest].gsub(/\s/,''))
        end
      end
    end
  end

  if @add && !@add.empty?
    node << x_node('add').tap do |n|
      @add.each do |ds|
        n << x_node('dsData').tap do |dsData|
          dsData << x_node('keyTag', ds[:key_tag].to_s)
          dsData << x_node('alg', ds[:alg].to_s)
          dsData << x_node('digestType', ds[:digest_type].to_s)
          dsData << x_node('digest', ds[:digest].gsub(/\s/,''))
        end
      end
    end
  end

  if @chg && !@chg.empty?
    # Nominet don't support maxSigLife so nothing happens here
  end

  node
end