Skip to content

Commit

Permalink
Minor fixes, grammar, wrong server, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 27, 2022
1 parent a7a7eba commit f7314d4
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions bounce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions messages_outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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{}

Expand Down
6 changes: 3 additions & 3 deletions postmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -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")
Expand All @@ -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
}
Expand Down
11 changes: 6 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package postmark

import (
"context"
"net/http"
)

// GetCurrentServer gets details for the server associated
// with the currently in-use server API Key
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)
Expand All @@ -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
}
20 changes: 10 additions & 10 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package postmark
import (
"context"
"fmt"
"net/http"
)

// Server represents a server registered in your Postmark account
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
12 changes: 6 additions & 6 deletions servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down
10 changes: 5 additions & 5 deletions stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit f7314d4

Please sign in to comment.