Class: EPP::Domain::Renew

Inherits:
Command
  • Object
show all
Defined in:
lib/epp-client/domain/renew.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, exp_date, period = nil) ⇒ Renew

Returns a new instance of Renew.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
# File 'lib/epp-client/domain/renew.rb', line 6

def initialize(name, exp_date, period = nil)
  @name, @exp_date = name, exp_date
  @exp_date = Time.parse(exp_date) if exp_date.kind_of?(String)

  @period_unit = period[-1,1]
  @period_val  = period.to_i.to_s
  
  raise ArgumentError, "period suffix must either be 'm' or 'y'" unless %w(m y).include?(@period_unit)
end

Instance Method Details

#nameObject



16
17
18
# File 'lib/epp-client/domain/renew.rb', line 16

def name
  'renew'
end

#to_xmlObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/epp-client/domain/renew.rb', line 20

def to_xml
  node = super
  node << domain_node('name', @name)
  node << domain_node('curExpDate', @exp_date.strftime("%Y-%m-%d"))

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

  node << p

  node
end