diff --git a/README.md b/README.md index ad0502b..9c2ccaf 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ vet Run the Go vet application ## Examples & Tests All unit tests and [examples](examples) run via [Github Actions](https://github.com/mrz1836/postmark/actions) and -uses [Go version 1.15.x](https://golang.org/doc/go1.15). View the [configuration file](.github/workflows/run-tests.yml). +uses [Go version 1.17.x](https://golang.org/doc/go1.17). View the [configuration file](.github/workflows/run-tests.yml). Run all tests (including integration tests) ```shell script diff --git a/bounce.go b/bounce.go index f3d20de..20ac1e7 100644 --- a/bounce.go +++ b/bounce.go @@ -61,11 +61,11 @@ type Bounce struct { Email string // BouncedAt: Timestamp of bounce BouncedAt time.Time - // DumpAvailable: Specifies whether or not you can get a raw dump from this bounce. Postmark does not store bounce dumps older than 30 days. + // DumpAvailable: Specifies whether you can get a raw dump from this bounce. Postmark does not store bounce dumps older than 30 days. DumpAvailable bool // Inactive: Specifies if the bounce caused Postmark to deactivate this email. Inactive bool - // CanActivate: Specifies whether or not you are able to reactivate this email. + // CanActivate: Specifies whether you are able to reactivate this email. CanActivate bool // Subject: Email subject Subject string @@ -116,7 +116,7 @@ type dumpResponse struct { Body string } -// GetBounceDump fetches a SMTP data dump for a single bounce +// GetBounceDump fetches an SMTP data dump for a single bounce func (client *Client) GetBounceDump(ctx context.Context, bounceID int64) (string, error) { res := dumpResponse{} path := fmt.Sprintf("bounces/%v/dump", bounceID) diff --git a/messages_outbound.go b/messages_outbound.go index ffb657e..e8c8b6c 100644 --- a/messages_outbound.go +++ b/messages_outbound.go @@ -138,7 +138,7 @@ type outboundMessageOpensResponse struct { } // GetOutboundMessagesOpens fetches a list of opens on the server -// It returns a Open slice, the total opens count, and any error that occurred +// It returns an Open slice, the total opens count, and any error that occurred // To get opens for a specific message, use GetOutboundMessageOpens() // Available options: http://developer.postmarkapp.com/developer-api-messages.html#message-opens func (client *Client) GetOutboundMessagesOpens(ctx context.Context, count int64, offset int64, options map[string]interface{}) ([]Open, int64, error) { @@ -161,7 +161,7 @@ func (client *Client) GetOutboundMessagesOpens(ctx context.Context, count int64, } // GetOutboundMessageOpens fetches a list of opens for a specific message -// It returns a Open slice, the total opens count, and any error that occurred +// It returns an Open slice, the total opens count, and any error that occurred func (client *Client) GetOutboundMessageOpens(ctx context.Context, messageID string, count int64, offset int64) ([]Open, int64, error) { res := outboundMessageOpensResponse{} diff --git a/postmark.go b/postmark.go index 3b01f67..60bf056 100644 --- a/postmark.go +++ b/postmark.go @@ -6,7 +6,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -68,7 +68,7 @@ func (client *Client) doRequest(ctx context.Context, opts parameters, dst interf if err != nil { return } - req.Body = ioutil.NopCloser(bytes.NewBuffer(payloadData)) + req.Body = io.NopCloser(bytes.NewBuffer(payloadData)) } req.Header.Add("Accept", "application/json") @@ -92,7 +92,7 @@ func (client *Client) doRequest(ctx context.Context, opts parameters, dst interf _ = res.Body.Close() }() var body []byte - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) if err != nil { return } diff --git a/server.go b/server.go index 6fefc15..adb355e 100644 --- a/server.go +++ b/server.go @@ -2,6 +2,7 @@ package postmark import ( "context" + "net/http" ) // GetCurrentServer gets details for the server associated @@ -9,7 +10,7 @@ import ( func (client *Client) GetCurrentServer(ctx context.Context) (Server, error) { res := Server{} err := client.doRequest(ctx, parameters{ - Method: "GET", + Method: http.MethodGet, Path: "server", TokenType: serverToken, }, &res) @@ -20,11 +21,11 @@ func (client *Client) GetCurrentServer(ctx context.Context) (Server, error) { // EditCurrentServer updates details for the server associated // with the currently in-use server API Key func (client *Client) EditCurrentServer(ctx context.Context, server Server) (Server, error) { - res := Server{} + // res := Server{} err := client.doRequest(ctx, parameters{ - Method: "PUT", + Method: http.MethodPut, Path: "server", TokenType: serverToken, - }, &res) - return res, err + }, &server) + return server, err } diff --git a/server_test.go b/server_test.go index 5197d84..a36f606 100644 --- a/server_test.go +++ b/server_test.go @@ -19,16 +19,16 @@ func TestGetCurrentServer(t *testing.T) { "Color": "red", "SmtpApiActivated": true, "RawEmailEnabled": false, - "DeliveryHookUrl": "http://hooks.example.com/delivery", + "DeliveryHookUrl": "https://hooks.example.com/delivery", "InboundAddress": "yourhash@inbound.postmarkapp.com", - "InboundHookUrl": "http://hooks.example.com/inbound", - "BounceHookUrl": "http://hooks.example.com/bounce", + "InboundHookUrl": "https://hooks.example.com/inbound", + "BounceHookUrl": "https://hooks.example.com/bounce", "IncludeBounceContentInHook": true, - "OpenHookUrl": "http://hooks.example.com/open", + "OpenHookUrl": "https://hooks.example.com/open", "PostFirstOpenOnly": false, "TrackOpens": false, "TrackLinks" : "None", - "ClickHookUrl" : "http://hooks.example.com/click", + "ClickHookUrl" : "https://hooks.example.com/click", "InboundDomain": "", "InboundHash": "yourhash", "InboundSpamThreshold": 0 @@ -59,16 +59,16 @@ func TestEditCurrentServer(t *testing.T) { "Color": "blue", "SmtpApiActivated": false, "RawEmailEnabled": false, - "DeliveryHookUrl": "http://hooks.example.com/delivery", + "DeliveryHookUrl": "https://hooks.example.com/delivery", "InboundAddress": "yourhash@inbound.postmarkapp.com", - "InboundHookUrl": "http://hooks.example.com/inbound", - "BounceHookUrl": "http://hooks.example.com/bounce", + "InboundHookUrl": "https://hooks.example.com/inbound", + "BounceHookUrl": "https://hooks.example.com/bounce", "IncludeBounceContentInHook": true, - "OpenHookUrl": "http://hooks.example.com/open", + "OpenHookUrl": "https://hooks.example.com/open", "PostFirstOpenOnly": false, "TrackOpens": false, "TrackLinks": "None", - "ClickHookUrl": "http://hooks.example.com/click", + "ClickHookUrl": "https://hooks.example.com/click", "InboundDomain": "", "InboundHash": "yourhash", "InboundSpamThreshold": 10 diff --git a/servers.go b/servers.go index cdbabd9..45f0b95 100644 --- a/servers.go +++ b/servers.go @@ -3,6 +3,7 @@ package postmark import ( "context" "fmt" + "net/http" ) // Server represents a server registered in your Postmark account @@ -17,7 +18,7 @@ type Server struct { ServerLink string // Color of the server in the rack screen. Purple Blue Turquoise Green Red Yellow Grey Color string - // SMTPAPIActivated specifies whether or not SMTP is enabled on this server. + // SMTPAPIActivated specifies whether SMTP is enabled on this server. SMTPAPIActivated bool `json:"SmtpApiActivated"` // RawEmailEnabled allows raw email to be sent with inbound. RawEmailEnabled bool @@ -46,7 +47,7 @@ type Server struct { func (client *Client) GetServer(ctx context.Context, serverID string) (Server, error) { res := Server{} err := client.doRequest(ctx, parameters{ - Method: "GET", + Method: http.MethodGet, Path: fmt.Sprintf("servers/%s", serverID), TokenType: accountToken, }, &res) @@ -55,11 +56,11 @@ func (client *Client) GetServer(ctx context.Context, serverID string) (Server, e // EditServer updates details for a specific server with serverID func (client *Client) EditServer(ctx context.Context, serverID string, server Server) (Server, error) { - res := Server{} + // res := Server{} err := client.doRequest(ctx, parameters{ - Method: "PUT", + Method: http.MethodPut, Path: fmt.Sprintf("servers/%s", serverID), TokenType: accountToken, - }, &res) - return res, err + }, &server) + return server, err } diff --git a/servers_test.go b/servers_test.go index 73f1b32..8631bfa 100644 --- a/servers_test.go +++ b/servers_test.go @@ -20,9 +20,9 @@ func TestGetServer(t *testing.T) { "SmtpApiActivated": true, "RawEmailEnabled": false, "InboundAddress": "yourhash@inbound.postmarkapp.com", - "InboundHookUrl": "http://hooks.example.com/inbound", - "BounceHookUrl": "http://hooks.example.com/bounce", - "OpenHookUrl": "http://hooks.example.com/open", + "InboundHookUrl": "https://hooks.example.com/inbound", + "BounceHookUrl": "https://hooks.example.com/bounce", + "OpenHookUrl": "https://hooks.example.com/open", "PostFirstOpenOnly": false, "TrackOpens": false, "InboundDomain": "", @@ -56,9 +56,9 @@ func TestEditServer(t *testing.T) { "SmtpApiActivated": false, "RawEmailEnabled": false, "InboundAddress": "yourhash@inbound.postmarkapp.com", - "InboundHookUrl": "http://hooks.example.com/inbound", - "BounceHookUrl": "http://hooks.example.com/bounce", - "OpenHookUrl": "http://hooks.example.com/open", + "InboundHookUrl": "https://hooks.example.com/inbound", + "BounceHookUrl": "https://hooks.example.com/bounce", + "OpenHookUrl": "https://hooks.example.com/open", "PostFirstOpenOnly": false, "TrackOpens": false, "InboundDomain": "", diff --git a/stats.go b/stats.go index 5a001db..bd9aaa6 100644 --- a/stats.go +++ b/stats.go @@ -54,7 +54,7 @@ func (client *Client) GetOutboundStats(ctx context.Context, options map[string]i // SendDay - send stats for a specific day type SendDay struct { - // Date - self explanatory + // Date - self-explanatory Date string // Sent - number of emails sent Sent int64 @@ -87,7 +87,7 @@ func (client *Client) GetSentCounts(ctx context.Context, options map[string]inte // BounceDay - bounce stats for a specific day type BounceDay struct { - // Date - self explanatory + // Date - self-explanatory Date string // HardBounce - number of hard bounces HardBounce int64 @@ -132,7 +132,7 @@ func (client *Client) GetBounceCounts(ctx context.Context, options map[string]in // SpamDay - spam complaints for a specific day type SpamDay struct { - // Date - self explanatory + // Date - self-explanatory Date string // SpamComplaint - number of spam complaints received SpamComplaint int64 @@ -166,7 +166,7 @@ func (client *Client) GetSpamCounts(ctx context.Context, options map[string]inte // TrackedDay - tracked emails sent on a specific day type TrackedDay struct { - // Date - self explanatory + // Date - self-explanatory Date string // Tracked - number of emails tracked sent Tracked int64 @@ -199,7 +199,7 @@ func (client *Client) GetTrackedCounts(ctx context.Context, options map[string]i // OpenedDay - opened outbound emails sent on a specific day type OpenedDay struct { - // Date - self explanatory + // Date - self-explanatory Date string // Opens - Indicates total number of opened emails. This total includes recipients who opened your email multiple times. Opens int64 diff --git a/templates.go b/templates.go index 20c833d..94faa3c 100644 --- a/templates.go +++ b/templates.go @@ -161,7 +161,7 @@ type TemplatedEmail struct { TemplateAlias string `json:",omitempty"` // TemplateModel: The model to be applied to the specified template to generate HtmlBody, TextBody, and Subject. TemplateModel map[string]interface{} `json:",omitempty"` - // InlineCSS: By default, if the specified template contains an HtmlBody, we will apply the style blocks as inline attributes to the rendered HTML content. You may opt-out of this behavior by passing false for this request field. + // InlineCSS: By default, if the specified template contains an HtmlBody, we will apply the style blocks as inline attributes to the rendered HTML content. You may opt out of this behavior by passing false for this request field. InlineCSS bool `json:"InlineCSS,omitempty"` // From: The sender email address. Must have a registered and confirmed Sender Signature. From string `json:",omitempty"`