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

Returns a new instance of Create.

Parameters:

  • name (String)
  • period (String)
  • nameservers (Array<String,Hash>)
  • registrant (String)
  • contacts (Hash<Symbol,String>)
  • auth_info (Hash<Symbol,String>)


17
18
19
20
21
22
23
24
25
26
# File 'lib/epp-client/domain/create.rb', line 17

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



28
29
30
# File 'lib/epp-client/domain/create.rb', line 28

def name
  'create'
end

#to_xmlObject



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/epp-client/domain/create.rb', line 32

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