1
1
package postmark
2
2
3
3
import (
4
+ "context"
4
5
"encoding/json"
5
6
"fmt"
6
7
"net/url"
@@ -27,10 +28,10 @@ type DeliveryStats struct {
27
28
}
28
29
29
30
// GetDeliveryStats returns delivery stats for the server
30
- func (client * Client ) GetDeliveryStats () (DeliveryStats , error ) {
31
+ func (client * Client ) GetDeliveryStats (ctx context. Context ) (DeliveryStats , error ) {
31
32
res := DeliveryStats {}
32
33
path := "deliverystats"
33
- err := client .doRequest (parameters {
34
+ err := client .doRequest (ctx , parameters {
34
35
Method : "GET" ,
35
36
Path : path ,
36
37
TokenType : serverToken ,
@@ -78,7 +79,7 @@ type bouncesResponse struct {
78
79
// GetBounces returns bounces for the server
79
80
// It returns a Bounce slice, the total bounce count, and any error that occurred
80
81
// Available options: http://developer.postmarkapp.com/developer-api-bounce.html#bounces
81
- func (client * Client ) GetBounces (count int64 , offset int64 , options map [string ]interface {}) ([]Bounce , int64 , error ) {
82
+ func (client * Client ) GetBounces (ctx context. Context , count int64 , offset int64 , options map [string ]interface {}) ([]Bounce , int64 , error ) {
82
83
res := bouncesResponse {}
83
84
84
85
values := & url.Values {}
@@ -91,7 +92,7 @@ func (client *Client) GetBounces(count int64, offset int64, options map[string]i
91
92
92
93
path := fmt .Sprintf ("bounces?%s" , values .Encode ())
93
94
94
- err := client .doRequest (parameters {
95
+ err := client .doRequest (ctx , parameters {
95
96
Method : "GET" ,
96
97
Path : path ,
97
98
TokenType : serverToken ,
@@ -100,10 +101,10 @@ func (client *Client) GetBounces(count int64, offset int64, options map[string]i
100
101
}
101
102
102
103
// GetBounce fetches a single bounce with bounceID
103
- func (client * Client ) GetBounce (bounceID int64 ) (Bounce , error ) {
104
+ func (client * Client ) GetBounce (ctx context. Context , bounceID int64 ) (Bounce , error ) {
104
105
res := Bounce {}
105
106
path := fmt .Sprintf ("bounces/%v" , bounceID )
106
- err := client .doRequest (parameters {
107
+ err := client .doRequest (ctx , parameters {
107
108
Method : "GET" ,
108
109
Path : path ,
109
110
TokenType : serverToken ,
@@ -116,10 +117,10 @@ type dumpResponse struct {
116
117
}
117
118
118
119
// GetBounceDump fetches a SMTP data dump for a single bounce
119
- func (client * Client ) GetBounceDump (bounceID int64 ) (string , error ) {
120
+ func (client * Client ) GetBounceDump (ctx context. Context , bounceID int64 ) (string , error ) {
120
121
res := dumpResponse {}
121
122
path := fmt .Sprintf ("bounces/%v/dump" , bounceID )
122
- err := client .doRequest (parameters {
123
+ err := client .doRequest (ctx , parameters {
123
124
Method : "GET" ,
124
125
Path : path ,
125
126
TokenType : serverToken ,
@@ -135,10 +136,10 @@ type activateBounceResponse struct {
135
136
// ActivateBounce reactivates a bounce for resending. Returns the bounce, a
136
137
// message, and any error that occurs
137
138
// TODO: clarify this with Postmark
138
- func (client * Client ) ActivateBounce (bounceID int64 ) (Bounce , string , error ) {
139
+ func (client * Client ) ActivateBounce (ctx context. Context , bounceID int64 ) (Bounce , string , error ) {
139
140
res := activateBounceResponse {}
140
141
path := fmt .Sprintf ("bounces/%v/activate" , bounceID )
141
- err := client .doRequest (parameters {
142
+ err := client .doRequest (ctx , parameters {
142
143
Method : "PUT" ,
143
144
Path : path ,
144
145
TokenType : serverToken ,
@@ -151,15 +152,14 @@ type bouncedTagsResponse struct {
151
152
}
152
153
153
154
// GetBouncedTags retrieves a list of tags that have generated bounced emails
154
- func (client * Client ) GetBouncedTags () ([]string , error ) {
155
+ func (client * Client ) GetBouncedTags (ctx context. Context ) ([]string , error ) {
155
156
var raw json.RawMessage
156
157
path := "bounces/tags"
157
- err := client .doRequest (parameters {
158
+ err := client .doRequest (ctx , parameters {
158
159
Method : "GET" ,
159
160
Path : path ,
160
161
TokenType : serverToken ,
161
162
}, & raw )
162
-
163
163
if err != nil {
164
164
return []string {}, err
165
165
}
0 commit comments