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.

Parameters:

  • name (String)

    Domain name to renew

  • exp_date (Time, String)

    Expiration date of the domain

  • period (String) (defaults to: nil)

    Renewal period in XXy years or XXm months. XX must be between 1 and 99.



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

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)

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

Instance Method Details

#nameObject



18
19
20
# File 'lib/epp-client/domain/renew.rb', line 18

def name
  'renew'
end

#to_xmlObject



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

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

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

    node << p
  end

  node
end