mirror of
https://github.com/hanzo-go/sendgrid.git
synced 2026-10-30 15:05:38 +00:00
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/hanzoai/sendgrid-go"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
// Retrieveemailstatisticsbyclienttype : Retrieve email statistics by client type.
|
|
// GET /clients/stats
|
|
func Retrieveemailstatisticsbyclienttype() {
|
|
apiKey := os.Getenv("YOUR_SENDGRID_APIKEY")
|
|
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("YOUR_SENDGRID_APIKEY")
|
|
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
|
|
}
|