git.iko.soy/typeable/mandrill
on release-0.5.2.1 help sign in
106 lines 2.8 kB history raw
1[![Build Status](https://travis-ci.org/adinapoli/mandrill.svg?branch=master)](https://travis-ci.org/adinapoli/mandrill)
2[![Coverage Status](https://img.shields.io/coveralls/adinapoli/mandrill.svg)](https://coveralls.io/r/adinapoli/mandrill)
4# Haskell Client for the Mandrill JSON API
6This module implement a low-level, 1:1 mapping API to
7the [Mandrill](http://mandrillapp.com) transactional email service.
9# Changelog
11## Version 0.5.2.1
13* Added `Functor`, `Foldable` and `Traversable` instances to `MandrillResponse` (Courtesy of @dredozubov)
15## Version 0.5.2.0
17* Added inbound calls (Courtesy of @mwotton)
19## Version 0.5.1.0
21* Relaxed the constraint on `aeson` to allow `0.11.0.0`.
23## Version 0.5.0.0
25* Changed the `MandrillHeaders` type synonym from `Value` to `Object`.
27* Changed the `mmsg_metadata` and `mmdt_values` fields from `MandrillVars` to `Object`.
29* Changed the `mmsg_global_merge_vars` and `mmvr_vars` fields from `[MandrillVars]` to `[MergeVar]`
31* Added the `MergeVar` data type:
33```haskell
34data MergeVar = MergeVar {
35 _mv_name :: !Text
36 , _mv_content :: Value
37 }
38```
40* Removed the `MandrillVars` type synonym.
42## Version 0.4.0.0
44* Modified the `Base64ByteString` type to accept another constructor. This
45 allows the user to pass already-encoded Base64 strings which might be coming
46 upstream.
48# Example
50This package was built with pragmatism and reuse in mind. This means
51this API comes in two flavours: an IO-based and an handy monad transformer
52which can be plugged in your stack of choice.
53Example:
55``` haskell
56{-# LANGUAGE OverloadedStrings #-}
57import Text.Email.Validate
58import Network.API.Mandrill
60main :: IO ()
61main = do
62 case validate "foo@example.com" of
63 Left err -> print $ "Invalid email!" ++ show err
64 Right addr -> runMandrill "MYTOKENHERE" $ do
65 let msg = "<p>My Html</p>"
66 res <- sendEmail (newTextMessage addr [addr] "Hello" msg)
67 case res of
68 MandrillSuccess k -> liftIO (print k)
69 MandrillFailure f -> liftIO (print f)
70```
72# Supported API versions
74* 1.0 (partially)
75 - [Users call](https://mandrillapp.com/api/docs/users.JSON.html) - 100%
76 + info.json
77 + ~~ping.json~~ (as **doesn't return valid json!**)
78 + ping2.json
79 + senders.json
80 - [Messages call](https://mandrillapp.com/api/docs/messages.JSON.html)
81 + send.json
83# Testing online API
85To test the online API, first build the package with tests enabled:
87```
88cabal install --enable-tests
89```
91Then export an environment variable with your Mandrill **Test** token:
93```
94export MANDRILL_API_KEY="YOURKEYGOESHERE"
95```
97And finally execute the testsuite:
99```
100cabal test
101```
103# Contributions
104This library scratches my own itches, but please fork away!
105Pull requests are encouraged to implement the part of the API
106you need.