-
Notifications
You must be signed in to change notification settings - Fork 7
/
domain.go
38 lines (31 loc) · 838 Bytes
/
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
package godaddygo
import (
"context"
"encoding/json"
"net/http"
"github.com/oze4/godaddygo/internal/exception"
)
func newDomain(config *Config) domain {
return domain{config}
}
type domain struct {
config *Config
}
func (d domain) Records() Records {
return newRecords(d.config)
}
func (d domain) GetDetails(ctx context.Context) (*DomainDetails, error) {
url := "/domains/" + d.config.domainName
result, err := makeDo(ctx, d.config, http.MethodGet, url, nil, 200)
if err != nil {
return nil, exception.GettingDomainDetails(err, d.config.domainName)
}
return readDomainDetailsResponse(result)
}
func readDomainDetailsResponse(r []byte) (*DomainDetails, error) {
var details DomainDetails
if err := json.Unmarshal(r, &details); err != nil {
return nil, exception.InvalidJSONResponse(err)
}
return &details, nil
}