53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/internetbs/domain_records.rb', line 53
def update(current_dns_record, new_dns_record)
@errors.clear
unless current_dns_record.valid? && new_dns_record.valid?
current_dns_record.each do |err|
@errors << "current: #{err}"
end
new_dns_record.each do |err|
@errors << "new: #{err}"
end
return false
end
params = {
'fullrecordname' => current_dns_record.full_record_name,
'type' => current_dns_record.type
}
if current_dns_record.value && dns_record.value
params.merge!({
'currentvalue' => current_dns_record.value,
'newvalue' => new_dns_record.value
})
end
if current_dns_record.ttl && \
new_dns_record.ttl && \
current_dns_record.ttl == new_dns_record.ttl
params.merge!({
'currentttl' => current_dns_record.ttl,
'newttl' => new_dns_record.ttl
})
end
if current_dns_record.type == 'MX' && \
current_dns_record.priority && \
new_dns_record.priority &&
current_dns_record.priority == new_dns_record.priority
params.merge!({
'currentpriority' => current_dns_record.priority,
'newpriority' => new_dns_record.priority
})
end
response = Client.post("/domain/dnsrecord/update", params)
code = response.code rescue ""
case code
when '200'
hash = JSON.parse(response.body)
@status = hash['status']
@transaction_id = hash['transactid']
unless @status == 'SUCCESS'
set_errors(response)
return false
end
return true
else
set_errors(response)
return false
end
end
|