Class: InternetBS::UpdateDomain

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

Instance Method Summary collapse

Methods inherited from Base

#inspect

Instance Method Details

#update!Object



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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/internetbs/update_domain.rb', line 15

def update!
  ensure_attribute_has_value :domain
  return false if @errors.any?
  
  @domain_extension = @domain.split('.').last
  
  params = {'domain' => @domain}
  
  params.merge!({'transferauthinfo' => @transfer_auth_info}) if @transfer_auth_info
  parmas.merge!({'registrarlock' => @registrar_lock}) if @registrar_lock
  params.merge!({'privatewhois' => @private_whois}) if @private_whois
  params.merge!({'autorenew' => @auto_renew ? 'YES' : 'NO'}) if @auto_renew
  
  if @nameservers.any?
    params.merge!({'ns_list' => @nameservers.join(',')})
  end
  
  if @contacts.any?
    @contacts.each do |contact|
      contact.domain_extension = @domain_extension
      params.merge!(contact.params)
    end
  end
  
  if @domain_extension == "tel"
    params.merge!({'telhostingaccount' => @tel_hosting_account}) if @tel_hosting_account
    params.merge!({'telhostingpassword' => @tel_hosting_password}) if @tel_hosting_password
    params.merge!({'telhidewhoisdata' => @tel_hide_whois_data ? 'YES' : 'NO'}) if @tel_hide_whois_data
  end
  
  response = Client.post('/domain/update', params)
  code = response.code rescue ""
  
  case code
  when '200'
    hash = JSON.parse(response.body)

    @status = hash['status']
    @transaction_id = hash['transactid']
    
    if @status == 'SUCCESS'
      
      debugger
    else
      set_errors(response)
      return false
    end
            
    return true
  else
    set_errors(response)
    return false
  end
end