-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdomain.go
95 lines (89 loc) · 1.82 KB
/
domain.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package labstack
import (
"github.com/go-resty/resty/v2"
"github.com/labstack/labstack-go/domain"
)
type (
DomainService struct {
resty *resty.Client
}
)
func (d *DomainService) DNS(req *domain.DNSRequest) (*domain.DNSResponse, error) {
res := new(domain.DNSResponse)
err := new(Error)
r, e := d.resty.R().
SetPathParams(map[string]string{
"type": req.Type,
"domain": req.Domain,
}).
SetResult(res).
SetError(err).
Get("/{type}/{domain}")
if e != nil {
return nil, &Error{
Message: err.Error(),
}
}
if isError(r.StatusCode()) {
return nil, err
}
return res, nil
}
func (d *DomainService) Search(req *domain.SearchRequest) (*domain.SearchResponse, error) {
res := new(domain.SearchResponse)
err := new(Error)
r, e := d.resty.R().
SetQueryParam("q", req.Q).
SetResult(res).
SetError(err).
Get("/search")
if e != nil {
return nil, &Error{
Message: err.Error(),
}
}
if isError(r.StatusCode()) {
return nil, err
}
return res, nil
}
func (d *DomainService) Status(req *domain.StatusRequest) (*domain.StatusResponse, error) {
res := new(domain.StatusResponse)
err := new(Error)
r, e := d.resty.R().
SetPathParams(map[string]string{
"domain": req.Domain,
}).
SetResult(res).
SetError(err).
Get("/status/{domain}")
if e != nil {
return nil, &Error{
Message: err.Error(),
}
}
if isError(r.StatusCode()) {
return nil, err
}
return res, nil
}
func (d *DomainService) Whois(req *domain.WhoisRequest) (*domain.WhoisResponse, error) {
res := new(domain.WhoisResponse)
err := new(Error)
r, e := d.resty.R().
SetPathParams(map[string]string{
"domain": req.Domain,
}).
SetResult(res).
SetError(err).
Get("/whois/{domain}")
if e != nil {
return nil, &Error{
Message: err.Error(),
}
}
if isError(r.StatusCode()) {
return nil, err
}
return res, nil
}