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
69
70
71
72
73
74
75
|
# File 'lib/internetbs/order_domain.rb', line 19
def purchase!
ensure_attribute_has_value :domain
return false if @errors.any?
@domain_extension = @domain.split('.').last
params = {
'domain' => @domain,
'currency' => @currency,
'period' => @period,
'ns_list' => @nameservers.join(',')
}
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!({'discountcode' => @discount_code}) if @discount_code
params.merge!({'autorenew' => @auto_renew ? 'YES' : 'NO'}) if @auto_renew
@contacts.each do |contact|
params.merge!(contact.params)
end
if @domain_extension == "tel"
params.merge!({
'telhostingaccount' => @tel_hosting_account,
'telhostingpassword' => @tel_hosting_password
})
if @tel_hide_whois_data
params.merge!({'telhidewhoisdata' => @tel_hide_whois_data ? 'YES' : 'NO'})
end
end
response = Client.post('/domain/create', params)
code = response.code rescue ""
case code
when '200'
hash = JSON.parse(response.body)
@status = hash['status']
@transaction_id = hash['transactid']
if @status == 'SUCCESS'
@currency = hash['currency']
@total_price = hash['price']
else
set_errors(response)
return false
end
return true
else
set_errors(response)
return false
end
end
|