Class: InternetBS::DomainHosts

Inherits:
Base
  • Object
show all
Defined in:
lib/internetbs/domain_hosts.rb

Instance Method Summary collapse

Methods inherited from Base

#inspect

Instance Method Details

#add(domain_host) ⇒ Object



7
8
9
# File 'lib/internetbs/domain_hosts.rb', line 7

def add(domain_host)
  set_record :create, domain_host
end

#fetchObject



11
12
13
14
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_hosts.rb', line 11

def fetch
  ensure_attribute_has_value :domain
  return false if @errors.any?
  
  params = {'domain' => @domain}
  params.merge!({'compactlist' => @compact ? 'YES' : 'NO'}) if @compact
    
  response = Client.get('/domain/host/list', params)
  code = response.code rescue ""
  
  case code
  when '200'
    hash = JSON.parse(response.body)

    @status = hash['status']
    @transaction_id = hash['transactid']
    
    if @status == 'SUCCESS'
      total_hosts = hash['total_hosts'].to_i
      if total_hosts > 0
        hash['host'].each do |key, value|
          @list << DomainHost.new(:host => value)
        end
      end
    else
      set_errors(response)
      return false
    end
    
    return true
  else
    set_errors(response)
    return false
  end
end

#remove(domain_host) ⇒ Object



47
48
49
# File 'lib/internetbs/domain_hosts.rb', line 47

def remove(domain_host)
  set_record :delete, domain_host
end

#update(domain_host) ⇒ Object



51
52
53
# File 'lib/internetbs/domain_hosts.rb', line 51

def update(domain_host)
  set_record :update, domain_host
end