Class: NominetEPP::Domain::CreateSecDNSExtension

Inherits:
RequestExtension show all
Defined in:
lib/nominet-epp/requests/domain/create.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) ⇒ CreateSecDNSExtension

Returns a new instance of CreateSecDNSExtension.

Raises:

  • (ArgumentError)


69
70
71
72
73
# File 'lib/nominet-epp/requests/domain/create.rb', line 69

def initialize(attributes)
  raise ArgumentError, "must provide Array of Hash or Hash of :key_tag, :alg, :digest_type and :digest" if attributes.nil? || attributes.empty?
  @attributes = attributes
  @namespaces = {}
end

Instance Method Details

#namespace_nameObject



78
79
80
# File 'lib/nominet-epp/requests/domain/create.rb', line 78

def namespace_name
  'secDNS'
end

#namespace_uriObject



75
76
77
# File 'lib/nominet-epp/requests/domain/create.rb', line 75

def namespace_uri
  NAMESPACE
end

#to_xmlObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/nominet-epp/requests/domain/create.rb', line 82

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

  Array(@attributes).each do |attributes|
    node << x_node('dsData').tap do |dsData|
      dsData << x_node('keyTag', attributes[:key_tag].to_s)
      dsData << x_node('alg', attributes[:alg].to_s)
      dsData << x_node('digestType', attributes[:digest_type].to_s)
      dsData << x_node('digest', attributes[:digest].gsub(/\s+/, ''))
    end
  end

  node
end