15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/internetbs/domain_availability.rb', line 15
def fetch
ensure_attribute_has_value :domain
return false if @errors.any?
params = {'domain' => @domain}
response = Client.get('/domain/check', params)
code = response.code rescue ""
case code
when '200'
hash = JSON.parse(response.body)
@status = hash['status']
@transaction_id = hash['transactid']
if @status == 'AVAILABLE'
@available = true
@max_registration_period = hash['maxregperiod']
@min_registration_period = hash['minregperiod']
@private_whois_allowed = hash['privatewhoisallowed'] == 'YES' ? true : false
@realtime_registration = hash['realtimeregistration'] == 'YES' ? true : false
@registrar_lock_allowed = hash['registrarlockallowed'] == 'YES' ? true : false
end
return true
else
set_errors(response)
return false
end
end
|