summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mailgun.cabal7
-rw-r--r--src/Rackspace/MailGun.hs21
2 files changed, 11 insertions, 17 deletions
diff --git a/mailgun.cabal b/mailgun.cabal
index b1603cf..6817d4d 100644
--- a/mailgun.cabal
+++ b/mailgun.cabal
@@ -1,5 +1,5 @@
name: mailgun
-version: 0.1.0.2
+version: 0.1.0.3
synopsis: Connector to Rackspace's Mailgun Service
description: Allows users to directly access Rackspace's Mailgun service
without having to work with the underlying REST service.
@@ -12,14 +12,13 @@ build-type: Simple
cabal-version: >=1.10
library
+ ghc-options: -Wall
exposed-modules: Rackspace.MailGun
- -- other-modules:
- -- other-extensions:
hs-source-dirs: src
default-language: Haskell2010
build-depends: base >=4.6 && <4.7
, text >=1.1.0.1
- , conduit >=1.0.17.1
+ , conduit >=1.1.0
, http-conduit >=2.0.0.8
, bytestring >=0.10.0.2
, network >=2.4.2.2
diff --git a/src/Rackspace/MailGun.hs b/src/Rackspace/MailGun.hs
index 17e7d8a..ab9e888 100644
--- a/src/Rackspace/MailGun.hs
+++ b/src/Rackspace/MailGun.hs
@@ -10,18 +10,13 @@ module Rackspace.MailGun
, sendWith
) where
-import Control.Failure
-import Control.Monad.Catch as C (MonadThrow)
+import Control.Monad.Catch
import Control.Monad.IO.Class
import Control.Monad.Trans.Control
-import Data.ByteString.Char8 as BS (ByteString, pack,
- putStrLn)
-import qualified Data.ByteString.Lazy.Char8 as LBS (ByteString)
-import Data.Conduit
-import qualified Data.Conduit.List as CL
-import Data.Text as T (Text, concat, pack)
-import Data.Text.Encoding (encodeUtf8)
-import Network (withSocketsDo)
+import qualified Data.ByteString.Char8 as BS
+import qualified Data.ByteString.Lazy.Char8 as LBS
+import Data.Text
+import Data.Text.Encoding
import Network.HTTP.Client.MultipartFormData
import Network.HTTP.Conduit
@@ -64,14 +59,14 @@ buildBase msg = partText "from" (from msg)
++ partMaybeText "subject" (subject msg)
++ buildTail msg
-sendMessage :: (Failure HttpException m, C.MonadThrow m, MonadBaseControl IO m, MonadIO m) =>
+sendMessage :: (MonadIO m, MonadBaseControl IO m, MonadThrow m) =>
String -> String -> Message -> m (Response LBS.ByteString)
sendMessage domain apiKey message = do
withManager $ \manager -> do
sendWith manager domain apiKey message
-sendWith :: (Failure HttpException m, C.MonadThrow m, MonadBaseControl IO m, MonadIO m) =>
- Manager -> String -> String -> Message -> m (Response LBS.ByteString)
+sendWith :: (MonadIO m, MonadBaseControl IO m, MonadThrow m) =>
+ Manager -> String -> String -> Message -> m (Response LBS.ByteString)
sendWith manager domain apiKey message = do
initReq <- parseUrl $ baseUrl ++ "/" ++ domain ++ "/messages"
let authReq = applyBasicAuth "api" (BS.pack apiKey) initReq