class WhoisXMLAPI::UnParsable

Public Instance Methods

parse(record) click to toggle source
# 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