forked from mrz1836/postmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
servers.go
66 lines (62 loc) · 2.35 KB
/
servers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package postmark
import (
"context"
"fmt"
"net/http"
)
// Server represents a server registered in your Postmark account
type Server struct {
// ID of server
ID int64
// Name of server
Name string
// APITokens associated with server.
APITokens []string `json:"ApiTokens"`
// ServerLink to your server overview page in Postmark.
ServerLink string
// Color of the server in the rack screen. Purple Blue Turquoise Green Red Yellow Grey
Color string
// SMTPAPIActivated specifies whether SMTP is enabled on this server.
SMTPAPIActivated bool `json:"SmtpApiActivated"`
// RawEmailEnabled allows raw email to be sent with inbound.
RawEmailEnabled bool
// InboundAddress is the inbound email address
InboundAddress string
// InboundHookURL to POST to every time an inbound event occurs.
InboundHookURL string `json:"InboundHookUrl"`
// BounceHookURL to POST to every time a bounce event occurs.
BounceHookURL string `json:"BounceHookUrl"`
// OpenHookURL to POST to every time an open event occurs.
OpenHookURL string `json:"OpenHookUrl"`
// PostFirstOpenOnly - If set to true, only the first open by a particular recipient will initiate the open webhook. Any
// subsequent opens of the same email by the same recipient will not initiate the webhook.
PostFirstOpenOnly bool
// TrackOpens indicates if all emails being sent through this server have open tracking enabled.
TrackOpens bool
// InboundDomain is the inbound domain for MX setup
InboundDomain string
// InboundHash is the inbound hash of your inbound email address.
InboundHash string
// InboundSpamThreshold is the maximum spam score for an inbound message before it's blocked.
InboundSpamThreshold int64
}
// GetServer fetches a specific server via serverID
func (client *Client) GetServer(ctx context.Context, serverID string) (Server, error) {
res := Server{}
err := client.doRequest(ctx, parameters{
Method: http.MethodGet,
Path: fmt.Sprintf("servers/%s", serverID),
TokenType: accountToken,
}, &res)
return res, err
}
// EditServer updates details for a specific server with serverID
func (client *Client) EditServer(ctx context.Context, serverID string, server Server) (Server, error) {
// res := Server{}
err := client.doRequest(ctx, parameters{
Method: http.MethodPut,
Path: fmt.Sprintf("servers/%s", serverID),
TokenType: accountToken,
}, &server)
return server, err
}