forked from getlantern/lantern
/
domains_autorenewals.go
45 lines (37 loc) · 1.27 KB
/
domains_autorenewals.go
1
2
3
4
5
6
7
8
9
10
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
package dnsimple
import (
"fmt"
)
// EnableAutoRenewal enables the auto-renewal feature for the domain.
//
// DNSimple API docs: http://developer.dnsimple.com/domains/autorenewal/#enable
func (s *DomainsService) EnableAutoRenewal(domain interface{}) (*Response, error) {
path := fmt.Sprintf("%s/auto_renewal", domainPath(domain))
res, err := s.client.post(path, nil, nil)
if err != nil {
return res, err
}
return res, nil
}
// DisableAutoRenewal disables the auto-renewal feature for the domain.
//
// DNSimple API docs: http://developer.dnsimple.com/domains/autorenewal/#disable
func (s *DomainsService) DisableAutoRenewal(domain interface{}) (*Response, error) {
path := fmt.Sprintf("%s/auto_renewal", domainPath(domain))
res, err := s.client.delete(path, nil)
if err != nil {
return res, err
}
return res, nil
}
// SetAutoRenewal is a convenient helper to enable/disable the auto-renewal feature for the domain.
//
// DNSimple API docs: http://developer.dnsimple.com/domains/autorenewal/#enable
// DNSimple API docs: http://developer.dnsimple.com/domains/autorenewal/#disable
func (s *DomainsService) SetAutoRenewal(domain interface{}, autoRenew bool) (*Response, error) {
if autoRenew {
return s.EnableAutoRenewal(domain)
} else {
return s.DisableAutoRenewal(domain)
}
}