-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomains.go
More file actions
84 lines (72 loc) · 2.59 KB
/
Copy pathdomains.go
File metadata and controls
84 lines (72 loc) · 2.59 KB
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
package bytesend
import "context"
type DNSRecord struct {
Type string `json:"type"`
Name string `json:"name"`
Value string `json:"value"`
TTL string `json:"ttl"`
Priority string `json:"priority,omitempty"`
Status string `json:"status"`
Recommended bool `json:"recommended,omitempty"`
}
type Domain struct {
ID int `json:"id"`
Name string `json:"name"`
TeamID int `json:"teamId"`
Status string `json:"status"`
Region string `json:"region"`
ClickTracking bool `json:"clickTracking"`
OpenTracking bool `json:"openTracking"`
PublicKey string `json:"publicKey"`
DKIMStatus string `json:"dkimStatus,omitempty"`
SPFDetails string `json:"spfDetails,omitempty"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
DMARCAdded bool `json:"dmarcAdded"`
IsVerifying bool `json:"isVerifying"`
ErrorMessage string `json:"errorMessage,omitempty"`
Subdomain string `json:"subdomain,omitempty"`
VerificationError string `json:"verificationError,omitempty"`
LastCheckedTime string `json:"lastCheckedTime,omitempty"`
DNSRecords []DNSRecord `json:"dnsRecords"`
}
type CreateDomainPayload struct {
Name string `json:"name"`
Region string `json:"region"`
}
type DeleteDomainResponse struct {
ID int `json:"id"`
Success bool `json:"success"`
Message string `json:"message"`
}
type VerifyDomainResponse struct {
Message string `json:"message"`
}
type DomainsService struct {
client *Client
}
func (s *DomainsService) List(ctx context.Context) ([]Domain, error) {
var resp []Domain
err := s.client.get(ctx, "/domains", &resp)
return resp, err
}
func (s *DomainsService) Create(ctx context.Context, payload CreateDomainPayload) (Domain, error) {
var resp Domain
err := s.client.post(ctx, "/domains", payload, &resp)
return resp, err
}
func (s *DomainsService) Get(ctx context.Context, id string) (Domain, error) {
var resp Domain
err := s.client.get(ctx, "/domains/"+id, &resp)
return resp, err
}
func (s *DomainsService) Verify(ctx context.Context, id string) (VerifyDomainResponse, error) {
var resp VerifyDomainResponse
err := s.client.put(ctx, "/domains/"+id+"/verify", nil, &resp)
return resp, err
}
func (s *DomainsService) Delete(ctx context.Context, id string) (DeleteDomainResponse, error) {
var resp DeleteDomainResponse
err := s.client.delete(ctx, "/domains/"+id, nil, &resp)
return resp, err
}