Class: WhoisXMLAPI::UnParsable

Inherits:
Result
  • Object
show all
Defined in:
lib/whoisxmlapi/un_parsable.rb

Instance Method Summary collapse

Methods inherited from Result

#complete?, #private?

Instance Method Details

#parse(record) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/whoisxmlapi/un_parsable.rb', line 3

def parse(record)
  self.domain = record['domainName']

  if record['registryData']
    self.record_created = record['registryData']['createdDate']
    self.record_updated = record['registryData']['updatedDate']
    self.record_expires = record['registryData']['expiresDate']
  end

  self.registrar = record['registrarName']
  self.nameservers = record['nameServers'] ? record['nameServers']['hostNames'] : []

  registrant_data = record['registrant']

  unless registrant_data
    if record['registryData'] and record['registryData']['registrant']
      registrant_data = record['registryData']['registrant']
    else
      registrant_data = {}
    end
  end
  if record
    registrant_data.merge({'email' => record['contactEmail']}) if record['contactEmail']
    self.registrant = WhoisXMLAPI::Contact.create(registrant_data)
    self.admin      = WhoisXMLAPI::Contact.create(record['administrativeContact']) if record['administrativeContact']
    self.tech       = WhoisXMLAPI::Contact.create(record['technicalContact']) if record['technicalContact']
    self.billing    = WhoisXMLAPI::Contact.create(record['billingContact']) if record['billingContact']
  end
end