Copyright | (c) 2012 Mark Hibberd |
---|---|
License | BSD3 |
Maintainer | Mark Hibberd <mark@hibberd.id.au> |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Library for postmarkapp.com HTTP Api.
To get start see some examples in the Network.Api.Postmark.Tutorial module.
Source and more information can be found at https://github.com/apiengine/postmark.
To experiment with a live demo try:
$ git clone https://github.com/apiengine/postmark $ cd postmark $ cabal install --only-dependencies && cabal configure -f demo && cabal build $ ./dist/build/postmark-demo/postmark-demo
Issues can be reported at https://github.com/apiengine/postmark/issues.
- data PostmarkSettings = PostmarkSettings {}
- type PostmarkApiToken = Text
- postmarkHttp :: PostmarkApiToken -> PostmarkSettings
- postmarkHttps :: PostmarkApiToken -> PostmarkSettings
- postmarkTestToken :: PostmarkApiToken
- postmarkHttpTest :: PostmarkSettings
- postmarkHttpsTest :: PostmarkSettings
- email :: Email -> PostmarkRequest' Sent
- emails :: [Email] -> PostmarkRequest' [Sent]
- data Email = Email {
- emailFrom :: Text
- emailTo :: [Text]
- emailCc :: [Text]
- emailBcc :: [Text]
- emailSubject :: Text
- emailTag :: Maybe Text
- emailHtml :: Maybe Text
- emailText :: Maybe Text
- emailReplyTo :: Text
- emailHeaders :: Map Text Text
- emailTrackOpens :: Maybe Bool
- emailTrackLinks :: Maybe TrackLinks
- emailAttachments :: [Attachment]
- defaultEmail :: Email
- emailWithTemplate :: EmailWithTemplate -> PostmarkRequest' Sent
- data EmailWithTemplate = EmailWithTemplate {
- templateId :: Int
- templateModel :: Map Text Text
- inlineCss :: Bool
- emailFrom' :: Text
- emailTo' :: [Text]
- emailCc' :: [Text]
- emailBcc' :: [Text]
- emailTag' :: Maybe Text
- emailReplyTo' :: Text
- emailHeaders' :: Map Text Text
- emailTrackOpens' :: Maybe Bool
- emailTrackLinks' :: Maybe TrackLinks
- emailAttachments' :: [Attachment]
- defaultEmailWithTemplate :: EmailWithTemplate
- data TrackLinks
- = None
- | HtmlAndText
- | HtmlOnly
- | TextOnly
- data Attachment = Attachment {}
- data Sent = Sent {}
- data PostmarkError = PostmarkError {}
- data PostmarkErrorType
- = PostmarkBadApiToken
- | PostmarkInvalidEmail
- | PostmarkSenderNotFound
- | PostmarkSenderNotConfirmed
- | PostmarkInvalidJson
- | PostmarkIncompatibleJson
- | PostmarkNotAllowed
- | PostmarkInactive
- | PostmarkBounceNotFound
- | PostmarkBounceQueryException
- | PostmarkJsonRequired
- | PostmarkTooManyMessages
- | PostmarkTemplateQueryException
- | PostmarkTemplateNotFound
- | PostmarkTemplateLimitWouldBeExceeded
- | PostmarkTemplateNoDataReceived
- | PostmarkTemplateRequiredFieldMissing
- | PostmarkTemplateFieldTooLarge
- | PostmarkTemplateFieldInvalid
- | PostmarkUnkownError Int
- request :: PostmarkSettings -> PostmarkRequest e a -> IO (PostmarkResponse e a)
- data PostmarkRequest e a where
- PostmarkRequest :: (FromJSON e, FromJSON a) => StdMethod -> Text -> RequestTransformer -> PostmarkRequest e a
- type PostmarkRequest' a = PostmarkRequest PostmarkError a
- data PostmarkResponse e a
- data PostmarkUnexpectedType
- type PostmarkResponse' a = PostmarkResponse PostmarkError a
- syntaxErr :: Int -> ByteString -> Text -> PostmarkResponse e a
- formatErr :: Int -> ByteString -> Text -> PostmarkResponse e a
Settings
data PostmarkSettings Source #
To construct PostmarkSettings
, use postmarkHttps
or
postmarkHttp
.
Or to use the test API instead, use postmarkHttpsTest
or
postmarkHttpTest
.
type PostmarkApiToken = Text Source #
The Postmark “server token” which is sent via the
X-Postmark-Server-Token
HTTP header. You can find your server
token under the “Credentials” tab on the Postmark website.
If you do not yet have a Postmark account, or if you want to send
test emails that don't actually get delivered, you may use
postmarkTestToken
.
https://postmarkapp.com/developer/api/overview#authentication
postmarkHttp :: PostmarkApiToken -> PostmarkSettings Source #
Constructs Postmark settings using the HTTP protocol and your API token.
HTTPS is recommended instead (postmarkHttps
).
postmarkHttps :: PostmarkApiToken -> PostmarkSettings Source #
Constructs Postmark settings using the HTTPS protocol and your API token.
Using the test token
postmarkTestToken :: PostmarkApiToken Source #
An API token that you can use when you want to send test emails that don't actually get delivered to the recipient.
https://postmarkapp.com/developer/api/overview#authentication
postmarkHttpTest :: PostmarkSettings Source #
Postmark settings using the HTTP protocol and the test API token
(postmarkTestToken
).
HTTPS is recommended instead (postmarkHttpsTest
).
postmarkHttpsTest :: PostmarkSettings Source #
Postmark settings using the HTTPS protocol and the test API token
(postmarkTestToken
).
Sending email
email :: Email -> PostmarkRequest' Sent Source #
Send a single email: http://developer.postmarkapp.com/developer-build.html
emails :: [Email] -> PostmarkRequest' [Sent] Source #
Bulk send emails: http://developer.postmarkapp.com/developer-build.html#batching-messages
Email data type. It is recommended that you use the defaultEmail function and selector syntax to build an email, e.g.:
defaultEmail { emailFrom = "you@yourdomain.com" , emailTo = "person@example.com" , emailSubject = "This is an example email!" }
|
defaultEmail :: Email Source #
Using a template
emailWithTemplate :: EmailWithTemplate -> PostmarkRequest' Sent Source #
Send a single email using a template: https://postmarkapp.com/developer/api/templates-api#email-with-template
data EmailWithTemplate Source #
EmailWithTemplate | |
|
Tracking links
data TrackLinks Source #
When “link tracking” is enabled, Postmark will record statistics when a user clicks on a link in an email. You can use this feature to determine if a particular recipient has clicked a link that was emailed to them.
https://postmarkapp.com/developer/user-guide/tracking-links#enabling-link-tracking
None | No links will be replaced or tracked. |
HtmlAndText | Links will be replaced in both HTML and text bodies. |
HtmlOnly | Links will be replaced in only the HTML body. You may want this option if you do not want encoded tracking links to appear in the plain text of an email. |
TextOnly | Links will be replaced in only the text body. |
Attachments
data Attachment Source #
Response type
Error types
data PostmarkError Source #
data PostmarkErrorType Source #
Lower-level API
Request
request :: PostmarkSettings -> PostmarkRequest e a -> IO (PostmarkResponse e a) Source #
Run the specified request with the specified settings.
data PostmarkRequest e a where Source #
PostmarkRequest :: (FromJSON e, FromJSON a) => StdMethod -> Text -> RequestTransformer -> PostmarkRequest e a |
type PostmarkRequest' a = PostmarkRequest PostmarkError a Source #
Response
data PostmarkResponse e a Source #
type PostmarkResponse' a = PostmarkResponse PostmarkError a Source #
syntaxErr :: Int -> ByteString -> Text -> PostmarkResponse e a Source #
formatErr :: Int -> ByteString -> Text -> PostmarkResponse e a Source #