/
clients.go
57 lines (52 loc) · 1.52 KB
/
clients.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
package main
import (
"fmt"
"log"
"os"
"github.com/sendgrid/sendgrid-go"
)
// Retrieveemailstatisticsbyclienttype : Retrieve email statistics by client type.
// GET /clients/stats
func Retrieveemailstatisticsbyclienttype() {
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/clients/stats", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["aggregated_by"] = "day"
queryParams["start_date"] = "2016-01-01"
queryParams["end_date"] = "2016-04-01"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
log.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
}
// Retrievestatsbyaspecificclienttype : Retrieve stats by a specific client type.
// GET /clients/{client_type}/stats
func Retrievestatsbyaspecificclienttype() {
apiKey := os.Getenv("SENDGRID_API_KEY")
host := "https://api.sendgrid.com"
request := sendgrid.GetRequest(apiKey, "/v3/clients/{client_type}/stats", host)
request.Method = "GET"
queryParams := make(map[string]string)
queryParams["aggregated_by"] = "day"
queryParams["start_date"] = "2016-01-01"
queryParams["end_date"] = "2016-04-01"
request.QueryParams = queryParams
response, err := sendgrid.API(request)
if err != nil {
log.Println(err)
} else {
fmt.Println(response.StatusCode)
fmt.Println(response.Body)
fmt.Println(response.Headers)
}
}
func main() {
// add your function calls here
}