Releases: mailjet/mailjet-apiv3-go
Release v3.1.0
#80 - return an error that users can do type assertions on
#79 - return an error when calling an unimplemented mock function to avoid getting panics
#78 - fix code examples in README
#77 - fix code snippet in README
#76 - add missing field IsExcludedFromCampaigns
in contact types
#75 - add missing ContactGetcontactslists
type
Fix content-type header value checking
The check of the content type header in http_client.go was a strict equal
Now the check has been made case insensitive and use strings.Contains to check for the content-type format
Sandbox mode patch
The SandBoxMode
field is now located in MessagesV31
struct
If you want to use the sandbox mode to test your emails validity, below is an example
package main
import (
"fmt"
"log"
"os"
mailjet "github.com/mailjet/mailjet-apiv3-go"
)
func main() {
m := mailjet.NewMailjetClient(
os.Getenv("MJ_APIKEY_PUBLIC"),
os.Getenv("MJ_APIKEY_PRIVATE"))
messagesInfo := []mailjet.InfoMessagesV31{
mailjet.InfoMessagesV31{
From: &mailjet.RecipientV31{
Email: "qwe@qwe.com",
Name: "Bob Patrick",
},
To: &mailjet.RecipientsV31{
mailjet.RecipientV31{
Email: "qwe@qwe.com",
},
},
Subject: "Send API v 3.1 testing",
TextPart: "Hey, that's pretty good!",
},
}
messages := mailjet.MessagesV31{Info: messagesInfo, SandBoxMode: true}
res, err := m.SendMailV31(&messages)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Data: %+v\n", res)
}
Send Api v3.1
In this release we introduced features to use our brand new Send API v3.1
This adds a new function SendMailV31
in the mailjet.Client structure located in mailjet_client.go
Example of implementation can be found in the README
Mocking support
We introduced mocking for the Mailjet driver
This change was aimed at improving the testability of the driver and so it comes with new unit tests based on these mocks
Here is how it works,
The driver is composed of several structs each having their own distinct functional scope
All the driver features are accessible from an instance of mailjet_client
Underneath it there are two major components that fuels these features
If you simply want to keep using the driver, you still can like you used to
However, if you want/need to do unit tests that involves the driver, here is how you can instantiate the driver to inject the HTTP and SMTP clients you need to make that happen
You may inject the HTTP and SMTP mocks available in this repository or you can also use your own as long as they respect the interfaces