Pure Haskell client for the Mandrill JSON API
Haskell Nix
Latest commit 3d8dc75 Jan 2, 2017 @adinapoli committed on GitHub Merge pull request #42 from adinapoli/v0.5.3.1
Relax Aeson upper bound (see fpco/stackage#2177 )
Permalink
Failed to load latest commit information.
examples Brushed a bit the docs Sep 7, 2014
src/Network/API
test
.gitignore
.hub Using CPP to make time-1.5 compile. Added GHC 7.10.1 to Travis Apr 30, 2015
.travis.yml
LICENSE Initial Aug 12, 2014
README.md
Setup.hs
default.nix
mandrill-nightly.yml Relax Aeson upper bound (see fpco/stackage#2177 ) Jan 2, 2017
mandrill.cabal
stack.yaml Release 0.5.1.0 Feb 9, 2016

README.md

Build Status Coverage Status

Haskell Client for the Mandrill JSON API

This module implement a low-level, 1:1 mapping API to the Mandrill transactional email service.

Changelog

Version 0.5.3.1

  • Relaxed upper bound on Aeson (see: fpco/stackage/issues/2177 )

Version 0.5.3.0

  • Added support for webhooks (thanks to @mwotton).

Version 0.5.2.3

  • Added support for aeson-1.0.0.0 by relaxing its upper bound.

Version 0.5.2.2

  • Added support for QuickCheck-2.9 by relaxing its upper bound.

Version 0.5.2.1

  • Added Functor, Foldable and Traversable instances to MandrillResponse (Courtesy of @dredozubov)

Version 0.5.2.0

  • Added inbound calls (Courtesy of @mwotton)

Version 0.5.1.0

  • Relaxed the constraint on aeson to allow 0.11.0.0.

Version 0.5.0.0

  • Changed the MandrillHeaders type synonym from Value to Object.

  • Changed the mmsg_metadata and mmdt_values fields from MandrillVars to Object.

  • Changed the mmsg_global_merge_vars and mmvr_vars fields from [MandrillVars] to [MergeVar]

  • Added the MergeVar data type:

data MergeVar = MergeVar {
      _mv_name    :: !Text
    , _mv_content :: Value
    }
  • Removed the MandrillVars type synonym.

Version 0.4.0.0

  • Modified the Base64ByteString type to accept another constructor. This allows the user to pass already-encoded Base64 strings which might be coming upstream.

Example

This package was built with pragmatism and reuse in mind. This means this API comes in two flavours: an IO-based and an handy monad transformer which can be plugged in your stack of choice. Example:

{-# LANGUAGE OverloadedStrings #-}
import Text.Email.Validate
import Network.API.Mandrill

main :: IO ()
main = do
  case validate "foo@example.com" of
    Left err   -> print $ "Invalid email!" ++ show err
    Right addr -> runMandrill "MYTOKENHERE" $ do
      let msg = "<p>My Html</p>"
      res <- sendEmail (newTextMessage addr [addr] "Hello" msg)
      case res of
        MandrillSuccess k -> liftIO (print k)
        MandrillFailure f -> liftIO (print f)

Supported API versions

Testing online API

To test the online API, first build the package with tests enabled:

cabal install --enable-tests

Then export an environment variable with your Mandrill Test token:

export MANDRILL_API_KEY="YOURKEYGOESHERE"

And finally execute the testsuite:

cabal test

Contributions

This library scratches my own itches, but please fork away! Pull requests are encouraged to implement the part of the API you need.