Class: NominetEPP::Domain::InfoResponse

Inherits:
BasicResponse show all
Defined in:
lib/nominet-epp/responses/domain/info_response.rb

Instance Method Summary collapse

Methods inherited from BasicResponse

#method, #respond_to?, #respond_to_missing?

Constructor Details

#initialize(response) ⇒ InfoResponse

Returns a new instance of InfoResponse.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 4

def initialize(response)
  raise ArgumentError, "must be an EPP::Response" unless response.kind_of?(EPP::Response)
  super EPP::Domain::InfoResponse.new(response)

  parse_truncated
  ext_inf_data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



68
69
70
71
72
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 68

def method_missing(method, *args, &block)
  return super unless @response.respond_to?(method)
  return @truncated[method.to_s] if @truncated.has_key?(method.to_s) # only do truncated if response would handle it
  @response.send(method, *args, &block)
end

Instance Method Details

#auto_billObject



32
33
34
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 32

def auto_bill
  @domain_infData['auto-bill']
end

#auto_periodObject



35
36
37
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 35

def auto_period
  @domain_infData['auto-period']
end

#client_idObject



54
55
56
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 54

def client_id
  @truncated['clID'] || @response.client_id
end

#creator_idObject



57
58
59
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 57

def creator_id
  @truncated['crID'] || @response.creator_id
end

#dsObject



64
65
66
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 64

def ds
  @secDNS_infData
end

#ext_inf_dataObject (protected)



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 81

def ext_inf_data
  @secDNS_infData = []
  @domain_infData = {}
  [@response.extension].flatten.compact.each do |node|
    next unless node.name == 'infData'
    node.find('//domain-ext:infData', namespaces).each do |infData|
      infData.children.each do |child|
        next if child.empty?

        key = child.name.gsub('-', '_')
        case key
        when 'notes'
          @domain_infData['notes'] ||= Array.new
          @domain_infData['notes'] << child.content.strip
        else
          @domain_infData[key] = child.content.strip
        end
      end
    end

    node.find('//secDNS:infData', namespaces).each do |infData|
      next if infData.empty?

      @secDNS_infData   = infData.find('secDNS:dsData', namespaces).map do |dsData|
        { :key_tag      => dsData.find('secDNS:keyTag', namespaces).first.content.strip,
          :alg          => dsData.find('secDNS:alg', namespaces).first.content.strip,
          :digest_type  => dsData.find('secDNS:digestType', namespaces).first.content.strip,
          :digest       => dsData.find('secDNS:digest', namespaces).first.content.strip}
      end
    end
  end
end

#first_billObject



26
27
28
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 26

def first_bill
  @domain_infData['first_bill']
end

#hostsObject



18
19
20
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 18

def hosts
  @hosts ||= @response.hosts.map { |ns| ns.sub(/\.$/,'') }
end

#nameserversObject



12
13
14
15
16
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 12

def nameservers
  @nameservers ||= @response.nameservers.each do |ns|
    ns['name'] = ns['name'].sub(/\.$/,'')
  end
end

#namespacesObject



74
75
76
77
78
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 74

def namespaces
  { 'secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1',
    'warning' => 'http://www.nominet.org.uk/epp/xml/std-warning-1.1',
    'domain-ext' => 'http://www.nominet.org.uk/epp/xml/domain-nom-ext-1.2' }
end

#next_billObject



38
39
40
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 38

def next_bill
  @domain_infData['next-bill']
end

#next_periodObject



41
42
43
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 41

def next_period
  @domain_infData['next-period']
end

#notesObject



47
48
49
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 47

def notes
  @domain_infData['notes']
end

#parse_truncatedObject (protected)



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 113

def parse_truncated
  @truncated = {}
  [@response.extension].flatten.compact.each do |node|
    next unless node.name == 'truncated-field'
    fieldName = node.attributes["field-name"]
    ns, field = fieldName.split(":", 2)
    content = node.content.strip
    content =~ /Full entry is '([^']*)'/
    content = $1

    @truncated[field.gsub('-','_')] = content
  end
end

#recur_billObject



29
30
31
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 29

def recur_bill
  @domain_infData['recur_bill']
end

#reg_statusObject



22
23
24
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 22

def reg_status
  @domain_infData['reg-status']
end

#renew_not_requiredObject



44
45
46
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 44

def renew_not_required
  @domain_infData['renew-not-required']
end

#resellerObject



50
51
52
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 50

def reseller
  @domain_infData['reseller']
end

#updator_idObject



60
61
62
# File 'lib/nominet-epp/responses/domain/info_response.rb', line 60

def updator_id
  @truncated['upID'] || @response.updator_id
end