-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.go
More file actions
67 lines (57 loc) · 1.81 KB
/
analytics.go
File metadata and controls
67 lines (57 loc) · 1.81 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
package bytesend
import "context"
type EmailTimeSeriesParams struct {
Days string
DomainID string
}
type EmailTimeSeriesEntry struct {
Date string `json:"date"`
Sent int `json:"sent"`
Delivered int `json:"delivered"`
Opened int `json:"opened"`
Clicked int `json:"clicked"`
Bounced int `json:"bounced"`
Complained int `json:"complained"`
}
type EmailTotals struct {
Sent int `json:"sent"`
Delivered int `json:"delivered"`
Opened int `json:"opened"`
Clicked int `json:"clicked"`
Bounced int `json:"bounced"`
Complained int `json:"complained"`
}
type EmailTimeSeriesResponse struct {
Result []EmailTimeSeriesEntry `json:"result"`
TotalCounts EmailTotals `json:"totalCounts"`
}
type ReputationMetricsParams struct {
DomainID string
}
type ReputationMetricsResponse struct {
Delivered int `json:"delivered"`
HardBounced int `json:"hardBounced"`
Complained int `json:"complained"`
BounceRate float64 `json:"bounceRate"`
ComplaintRate float64 `json:"complaintRate"`
}
type AnalyticsService struct {
client *Client
}
func (s *AnalyticsService) EmailTimeSeries(ctx context.Context, params EmailTimeSeriesParams) (EmailTimeSeriesResponse, error) {
path := s.client.buildPath("/analytics/email-time-series", map[string]string{
"days": params.Days,
"domainId": params.DomainID,
})
var resp EmailTimeSeriesResponse
err := s.client.get(ctx, path, &resp)
return resp, err
}
func (s *AnalyticsService) ReputationMetrics(ctx context.Context, params ReputationMetricsParams) (ReputationMetricsResponse, error) {
path := s.client.buildPath("/analytics/reputation-metrics", map[string]string{
"domainId": params.DomainID,
})
var resp ReputationMetricsResponse
err := s.client.get(ctx, path, &resp)
return resp, err
}