A Go library to make integration with Listrak's REST API easier to implement and maintain.
Everything uses Go's standard library
Each major Go release is supported until there are two newer major releases. It is strongly advised to stay within the security window of updates for Go if possible. However, this is not always possible in all projects. For that reason, there is a low barrier of entry for this to be included in existing projects.
The error json responses have been saved to variables (Sentinel errors). As many of the errors as exclusive to particular status codes this can infer response status codes as well as handle errors.
All API endpoints are implemented
Transactional emails only
Not Implemented
Not Implemented
go get github.com/dasper/listrak
Once included, how you store and pass your Listrak's id and secret is up to you. Only one integration is allowed to be initialized at a time. This limitation is in place to ensure the integrity of the Oauth2 bearer token as well as provide passive refreshing of the token.
err := listrak.Initialize("id", "secret")
if err != nil {
return
}
smsRequest := sms.NewClient()
shortCodes, err := smsRequest.GetShortCodeCollection()
if err != nil {
return
}
for _, item := range shortCodes.Data {
phoneList, err := smsRequest.GetListCollection(item.ShortCodeID)
if err != nil {
return
}
for _, phone := range phoneList.Data {
fmt.Println("Name", phone.PhoneListName)
fmt.Println("Created At", phone.CreateDate)
}
}
Wrapping errors and utilizing errors.Is()
could be beneficial as REST APIs have many potential points of failures and wrapped errors could allow attempting graceful recoveries in certain situations while still returning all relivant messages.