Class: KonoEppClient::Commands::CreateDomain

Inherits:
Command
  • Object
show all
Defined in:
lib/kono_epp_client/commands/create_domain.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CreateDomain

Returns a new instance of CreateDomain.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
# File 'lib/kono_epp_client/commands/create_domain.rb', line 3

def initialize(options)
  super(nil, nil)

  command = root.elements['command']
  create = command.add_element("create")

  domain_create = create.add_element("domain:create", {"xmlns:domain" => "urn:ietf:params:xml:ns:domain-1.0",
                                                       "xsi:schemaLocation" => "urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"})

  name = domain_create.add_element "domain:name"
  name.text = options[:name]

  domain_ns = domain_create.add_element "domain:ns"

  options[:nameservers].each do |ns|
    host_attr = domain_ns.add_element "domain:hostAttr"
    host_name = host_attr.add_element "domain:hostName"

    host_name.text = ns[0]

    # FIXME IPv6
    if ns[1]
      host_addr = host_attr.add_element "domain:hostAddr", {"ip" => "v4"}
      host_addr.text = ns[1]
    end
  end

  domain_registrant = domain_create.add_element "domain:registrant"
  domain_registrant.text = options[:registrant]

  domain_contact = domain_create.add_element "domain:contact", {"type" => "admin"}
  domain_contact.text = options[:admin]

  domain_contact = domain_create.add_element "domain:contact", {"type" => "tech"}
  domain_contact.text = options[:tech]

  domain_authinfo = domain_create.add_element "domain:authInfo"

  domain_pw = domain_authinfo.add_element "domain:pw"
  domain_pw.text = options[:authinfo]

  if options[:dns_sec_data] and options[:dns_sec_data].any?
    extension = command.elements['extension'] || command.add_element("extension")

    create_list = extension.add_element("secDNS:create", {"xmlns:secDNS"=> "urn:ietf:params:xml:ns:secDNS-1.1"})

    options[:dns_sec_data].each do |d|
      create_list.add_element(d)
    end
  end

end