forked from namecheap/go-namecheap-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains_get_info.go
58 lines (47 loc) · 1.53 KB
/
domains_get_info.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
package namecheap
import (
"encoding/xml"
"fmt"
)
type DomainsGetInfoResponse struct {
XMLName *xml.Name `xml:"ApiResponse"`
Errors *[]struct {
Message *string `xml:",chardata"`
Number *string `xml:"Number,attr"`
} `xml:"Errors>Error"`
CommandResponse *DomainsGetInfoCommandResponse `xml:"CommandResponse"`
}
type DomainsGetInfoCommandResponse struct {
DomainDNSGetListResult *DomainsGetInfoResult `xml:"DomainGetInfoResult"`
}
type DomainsGetInfoResult struct {
DomainName *string `xml:"DomainName,attr"`
IsPremium *bool `xml:"IsPremium,attr"`
PremiumDnsSubscription *PremiumDnsSubscription `xml:"PremiumDnsSubscription"`
DnsDetails *DnsDetails `xml:"DnsDetails"`
}
type PremiumDnsSubscription struct {
IsActive *bool `xml:"IsActive"`
}
type DnsDetails struct {
ProviderType *string `xml:"ProviderType,attr"`
IsUsingOurDNS *bool `xml:"IsUsingOurDNS,attr"`
Nameservers *[]string `xml:"Nameserver"`
}
func (ds *DomainsService) GetInfo(domain string) (*DomainsGetInfoCommandResponse, error) {
var response DomainsGetInfoResponse
params := map[string]string{
"Command": "namecheap.domains.getInfo",
"DomainName": domain,
"HostName": domain,
}
_, err := ds.client.DoXML(params, &response)
if err != nil {
return nil, err
}
if response.Errors != nil && len(*response.Errors) > 0 {
apiErr := (*response.Errors)[0]
return nil, fmt.Errorf("%s (%s)", *apiErr.Message, *apiErr.Number)
}
return response.CommandResponse, nil
}