Class: EPP::Domain::Create

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

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 = {}) ⇒ EPP::Domain::Create

Domain creation command.

Examples:

Create a domain

command = EPP::Domain::Create.new('example.com',
  period: '1y', registrant: 'test9023742684',
  auth_info: { pw: 'domainpassword' },
  contacts: { admin: 'admin123', tech: 'admin123', billing: 'admin123' },
  nameservers: ['ns1.test.host', 'ns2.test.host']
)

Create a domain with nameserver glue

command = EPP::Domain::Create.new('example.com',
  period: '1y', registrant: 'test9023742684',
  auth_info: { pw: 'domainpassword' },
  contacts: { admin: 'admin123', tech: 'admin123', billing: 'admin123' },
  nameservers: [
    {name: 'ns1.example.com', ipv4: '198.51.100.53'}
    {name: 'ns2.example.com', ipv4: '198.51.100.54'}
  ]
)

Parameters:

  • name (String)

    Name of domain to create

  • options (Hash) (defaults to: {})

    Options to use to create the domain

Options Hash (options):

  • period (String)

    Years or months period to create the domain for

  • Array (Array<String,Hash>)

    or hash of nameservers

  • registrant (String)

    Contact handle to use as registrant

  • contacts (Hash<Symbol,String>)

    Hash of admin, tech, billing contacts

  • auth_info (Hash<Symbol,String>)

    Hash of auth info



35
36
37
38
39
40
41
42
43
44
# File 'lib/epp-client/domain/create.rb', line 35

def initialize(name, options = {})
  @name = name
  @period = options.delete(:period) || '1y'
  @nameservers = Array(options.delete(:nameservers))
  @registrant = options.delete(:registrant)
  @contacts = options.delete(:contacts)
  @auth_info = options.delete(:auth_info)

  @period_val, @period_unit = validate_period(@period)
end

Instance Method Details

#nameObject



46
47
48
# File 'lib/epp-client/domain/create.rb', line 46

def name
  'create'
end

#to_xmlObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/epp-client/domain/create.rb', line 50

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

  if @period_val && @period_unit
    p = domain_node('period', @period_val)
    p['unit'] = @period_unit

    node << p
  end

  unless @nameservers.empty?
    node << nameservers_to_xml(@nameservers)
  end

  node << domain_node('registrant', @registrant) if @registrant

  contacts_to_xml(node, @contacts)

  node << auth_info_to_xml(@auth_info) unless @auth_info.empty?

  node
end