Documentation ¶
Overview ¶
Package sendgrid is a utiliuty package for interfacing with Sendgrid, a third party transactional email provider
Index ¶
- Constants
- Variables
- func AddContacts(apiKey string, data *AddContactData) error
- func FieldDefinitions(apiKey string) (string, error)
- func GetFirstRecipient(msg *sgmail.SGMailV3) (recipient string, err error)
- func MarketingLists(apiKey, pageToken string) (string, error)
- func WriteMIME(msg *sgmail.SGMailV3, path string) error
- type AddContactData
- type Contact
Constants ¶
const ( Host = "https://api.sendgrid.com" ContactsEP = "/v3/marketing/contacts" ListsEP = "/v3/marketing/lists" FieldsEP = "/v3/marketing/field_definitions" )
constants for working with sendgrid; didn't make them configurable as these are dictated by the vendor and this is a vendor specific package
Variables ¶
var (
ErrNoRecipientFound = errors.New("no recipient found")
)
Functions ¶
func AddContacts ¶
func AddContacts(apiKey string, data *AddContactData) error
AddContacts to SendGrid marketing list
func FieldDefinitions ¶
FieldDefinitions gets defs from SendGrid - get back all the definitions to re-use them in requests
func GetFirstRecipient ¶
GetFirstRecipient is used to extract the recipient email address from a `SGMailV3` object. It iterates through the personalizations and recipients of the email and returns the first recipient's email address. If no recipient is found, it returns an error
func MarketingLists ¶
MarketingLists fetches lists of contacts from SendGrid
Types ¶
type AddContactData ¶
type AddContactData struct { ListIDs []string `json:"list_ids"` Contacts []*Contact `json:"contacts"` }
AddContactData is a struct holding the list(s) to add to as well as a pointer to Contact info to populate
type Contact ¶
type Contact struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` Country string `json:"country"` }
Contact contains contact information for a user, for adding users to marketing lists and sending emails; note that Contact is also simply a "type" to use when sending emails via sendgrid and doesn't require you to create + fetch a "contact" from their API
func (Contact) FullName ¶
FullName attempts to construct the contact's full name from existing name fields