func newDriver(config map[string]interface{}) (drivers.Driver, error) {
	d := &SendGridDriver{}

	if config["apiUser"] != nil {
		d.Client = sendgrid.NewSendGridClient(config["apiUser"].(string), config["apiKey"].(string))
	} else {
		d.Client = sendgrid.NewSendGridClientWithApiKey(config["apiKey"].(string))
	}

	if sender := config["defaultFrom"]; sender != nil {
		d.DefaultFromEmail = sender.(string)
	}
	if sender := config["defaultFromName"]; sender != nil {
		d.DefaultFromName = sender.(string)
	}
	return d, nil
}
示例#2
0
func NewSendgridExporter(username, password string) *SendgridExporter {
	return &SendgridExporter{
		Client: sendgrid.NewSendGridClient(username, password),
	}
}