git.iko.soy/typeable/mandrill
on master help sign in
add inbound calls to mandrill
commit22f751a1b688e96fdab65a671a1fcd0e9f9aa49b authorMark Wotton <mwotton@gmail.com> dateMon 25 Apr 2016, 16:59 (10 years ago) parentfd2e343
11 files changed+259−111
mandrill.cabal+1 src/Network/API/Mandrill.hs+14−14 src/Network/API/Mandrill/HTTP.hs+9−9 src/Network/API/Mandrill/Inbound.hs+82 src/Network/API/Mandrill/Messages.hs+4−4 src/Network/API/Mandrill/Settings.hs+14−7 src/Network/API/Mandrill/Types.hs+57−57 test/Main.hs+11−7 test/Online.hs+25−7 test/RawData.hs+22−4 test/Tests.hs+20−2
mandrill.cabal+1
@@ -25,6 +25,7 @@ library
2525 Network.API.Mandrill.Users.Types
2626 Network.API.Mandrill.Messages
2727 Network.API.Mandrill.Messages.Types
28+ Network.API.Mandrill.Inbound
2829 other-modules:
2930 Network.API.Mandrill.Utils
3031 Network.API.Mandrill.HTTP
src/Network/API/Mandrill.hs+14−14
@@ -20,19 +20,19 @@ module Network.API.Mandrill (
2020 -- $exampleusage
2121 ) where
2222
23−import Control.Monad.Reader
24−import Control.Lens
25−import Data.Time
26−import Text.Blaze.Html
27−import Network.API.Mandrill.Types as M
28−import Network.API.Mandrill.Messages as M
29−import Network.API.Mandrill.Messages.Types as M
30−import Network.API.Mandrill.Trans as M
31−import Data.Monoid
32−import Text.Email.Validate
33−import qualified Data.Text as T
34−import qualified Data.Aeson as JSON
35−import qualified Data.HashMap.Strict as H
23+import Control.Lens
24+import Control.Monad.Reader
25+import qualified Data.Aeson as JSON
26+import qualified Data.HashMap.Strict as H
27+import Data.Monoid
28+import qualified Data.Text as T
29+import Data.Time
30+import Network.API.Mandrill.Messages as M
31+import Network.API.Mandrill.Messages.Types as M
32+import Network.API.Mandrill.Trans as M
33+import Network.API.Mandrill.Types as M
34+import Text.Blaze.Html
35+import Text.Email.Validate
3636
3737{- $exampleusage
3838
@@ -144,7 +144,7 @@ newTextMessage f t subj txt = let body = unsafeMkMandrillHtml txt in
144144-- 'MandrillMessage' and this function will send an email inside a
145145-- 'MandrillT' transformer. You are not forced to use the 'MandrillT' context
146146-- though. Have a look at "Network.API.Mandrill.Messages" for an IO-based,
147−-- low lever function for sending email.
147+-- low level function for sending email.
148148sendEmail :: MonadIO m
149149 => MandrillMessage
150150 -> MandrillT m (MandrillResponse [MessagesResponse])
src/Network/API/Mandrill/HTTP.hs+9−9
@@ -1,15 +1,15 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Network.API.Mandrill.HTTP where
33
4−import Network.API.Mandrill.Settings
5−import Network.API.Mandrill.Types
6−import qualified Data.Text as T
7−import Data.Monoid
8−import Data.Aeson
9−import Control.Applicative
10−import Network.HTTP.Types
11−import Network.HTTP.Client
12−import Network.HTTP.Client.TLS
4+import Control.Applicative
5+import Data.Aeson
6+import Data.Monoid
7+import qualified Data.Text as T
8+import Network.API.Mandrill.Settings
9+import Network.API.Mandrill.Types
10+import Network.HTTP.Client
11+import Network.HTTP.Client.TLS
12+import Network.HTTP.Types
1313
1414toMandrillResponse :: (MandrillEndpoint ep, FromJSON a, ToJSON rq)
1515 => ep
src/Network/API/Mandrill/Inbound.hsnew file+82
@@ -0,0 +1,82 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+module Network.API.Mandrill.Inbound where
3+import Control.Lens
4+import Data.Aeson (FromJSON, ToJSON, parseJSON,
5+ toJSON)
6+import Data.Aeson.TH (defaultOptions, deriveJSON)
7+import Data.Aeson.Types (fieldLabelModifier)
8+import Data.Text (Text)
9+import Network.API.Mandrill.HTTP (toMandrillResponse)
10+import Network.API.Mandrill.Settings
11+import Network.API.Mandrill.Types
12+import Network.HTTP.Client (Manager)
13+
14+data DomainAddRq =
15+ DomainAddRq
16+ { _darq_key :: MandrillKey
17+ , _darq_domain :: Text
18+ } deriving Show
19+
20+makeLenses ''DomainAddRq
21+deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''DomainAddRq
22+
23+data DomainAddResponse =
24+ DomainAddResponse
25+ { _dares_domain :: Text
26+ , _dares_created_at :: MandrillDate
27+ , _dares_valid_mx :: Bool
28+ } deriving Show
29+
30+
31+
32+makeLenses ''DomainAddResponse
33+deriveJSON defaultOptions { fieldLabelModifier = drop 7 } ''DomainAddResponse
34+
35+data RouteAddResponse =
36+ RouteAddResponse
37+ { _rares_id :: Text
38+ , _rares_pattern :: Text
39+ , _rares_url :: Text
40+ } deriving Show
41+
42+
43+
44+makeLenses ''RouteAddResponse
45+deriveJSON defaultOptions { fieldLabelModifier = drop 7 } ''RouteAddResponse
46+
47+data RouteAddRq =
48+ RouteAddRq
49+ { _rarq_key :: Text
50+ , _rarq_domain :: Text
51+ , _rarq_pattern :: Text
52+ , _rarq_url :: Text
53+ } deriving Show
54+
55+makeLenses ''RouteAddRq
56+deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''RouteAddRq
57+
58+
59+
60+
61+
62+addDomain :: MandrillKey
63+ -- ^ The API key
64+ -> Text
65+ -- ^ The domain to add
66+ -> Maybe Manager
67+ -> IO (MandrillResponse DomainAddResponse)
68+addDomain k dom = toMandrillResponse DomainsAdd (DomainAddRq k dom)
69+
70+
71+
72+addRoute :: MandrillKey
73+ -- ^ The API key
74+ -> Text
75+ -- ^ The domain to add
76+ -> Text
77+ -- ^ the pattern including wildcards
78+ -> Text
79+ -- ^ URL to forward to
80+ -> Maybe Manager
81+ -> IO (MandrillResponse RouteAddResponse)
82+addRoute k dom pattern forward = toMandrillResponse RoutesAdd (RouteAddRq k dom pattern forward)
src/Network/API/Mandrill/Messages.hs+4−4
@@ -1,13 +1,13 @@
11
22module Network.API.Mandrill.Messages where
33
4−import Network.API.Mandrill.Types
4+import qualified Data.Text as T
5+import Data.Time
6+import Network.API.Mandrill.HTTP
57import Network.API.Mandrill.Messages.Types
68import Network.API.Mandrill.Settings
7−import Network.API.Mandrill.HTTP
9+import Network.API.Mandrill.Types
810import Network.HTTP.Client
9−import Data.Time
10−import qualified Data.Text as T
1111
1212--------------------------------------------------------------------------------
1313-- | Send a new transactional message through Mandrill
src/Network/API/Mandrill/Settings.hs+14−7
@@ -15,16 +15,23 @@ data MandrillCalls =
1515 -- Messages API
1616 | MessagesSend
1717 | MessagesSendTemplate
18− | MessagesSearch deriving Show
18+ | MessagesSearch
19+ -- Inbound API
20+ | RoutesAdd
21+ | DomainsAdd
22+
23+ deriving Show
1924
2025class MandrillEndpoint ep where
2126 toUrl :: ep -> T.Text
2227
2328instance MandrillEndpoint MandrillCalls where
24− toUrl UsersInfo = "users/info.json"
25− toUrl UsersPing = "users/ping.json"
26− toUrl UsersPing2 = "users/ping2.json"
27− toUrl UsersSenders = "users/senders.json"
28− toUrl MessagesSend = "messages/send.json"
29+ toUrl UsersInfo = "users/info.json"
30+ toUrl UsersPing = "users/ping.json"
31+ toUrl UsersPing2 = "users/ping2.json"
32+ toUrl UsersSenders = "users/senders.json"
33+ toUrl MessagesSend = "messages/send.json"
2934 toUrl MessagesSendTemplate = "messages/send-template.json"
30− toUrl MessagesSearch = "messages/search.json"
35+ toUrl MessagesSearch = "messages/search.json"
36+ toUrl DomainsAdd = "inbound/add-domain.json"
37+ toUrl RoutesAdd = "inbound/add-route.json"
src/Network/API/Mandrill/Types.hs+57−57
@@ -1,34 +1,34 @@
1−{-# LANGUAGE TemplateHaskell #-}
2−{-# LANGUAGE CPP #-}
3−{-# LANGUAGE RankNTypes #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE RankNTypes #-}
44{-# LANGUAGE ScopedTypeVariables #-}
5−{-# LANGUAGE OverloadedStrings #-}
5+{-# LANGUAGE TemplateHaskell #-}
66module Network.API.Mandrill.Types where
77
8−import Network.API.Mandrill.Utils
9−import Test.QuickCheck
10−import Text.Email.Validate
8+import Control.Applicative
119import Data.Char
1210import Data.Maybe
1311import Data.Time
14−import Control.Applicative
12+import Network.API.Mandrill.Utils
13+import Test.QuickCheck
14+import Text.Email.Validate
1515#if MIN_VERSION_time(1,5,0)
16−import Data.Time.Format (TimeLocale, defaultTimeLocale)
16+import Data.Time.Format (TimeLocale, defaultTimeLocale)
1717#else
18−import System.Locale (TimeLocale, defaultTimeLocale)
18+import System.Locale (TimeLocale, defaultTimeLocale)
1919#endif
20−import qualified Data.ByteString as B
21−import qualified Data.ByteString.Base64 as Base64
22−import qualified Data.HashMap.Strict as H
23−import qualified Data.Text as T
24−import qualified Data.Text.Encoding as TL
25−import qualified Data.Text.Lazy as TL
2620import Control.Lens
27−import Data.Monoid
2821import Data.Aeson
29−import Data.Aeson.Types
3022import Data.Aeson.TH
31−import qualified Text.Blaze.Html as Blaze
23+import Data.Aeson.Types
24+import qualified Data.ByteString as B
25+import qualified Data.ByteString.Base64 as Base64
26+import qualified Data.HashMap.Strict as H
27+import Data.Monoid
28+import qualified Data.Text as T
29+import qualified Data.Text.Encoding as TL
30+import qualified Data.Text.Lazy as TL
31+import qualified Text.Blaze.Html as Blaze
3232import qualified Text.Blaze.Html.Renderer.Text as Blaze
3333
3434
@@ -41,9 +41,9 @@ timeParse = parseTime
4141
4242--------------------------------------------------------------------------------
4343data MandrillError = MandrillError {
44− _merr_status :: !T.Text
45− , _merr_code :: !Int
46− , _merr_name :: !T.Text
44+ _merr_status :: !T.Text
45+ , _merr_code :: !Int
46+ , _merr_name :: !T.Text
4747 , _merr_message :: !T.Text
4848 } deriving Show
4949
@@ -119,9 +119,9 @@ instance FromJSON MandrillEmail where
119119data MandrillRecipient = MandrillRecipient {
120120 _mrec_email :: MandrillEmail
121121 -- ^ The email address of the recipient
122− , _mrec_name :: Maybe T.Text
122+ , _mrec_name :: Maybe T.Text
123123 -- ^ The optional display name to use for the recipient
124− , _mrec_type :: Maybe MandrillRecipientTag
124+ , _mrec_type :: Maybe MandrillRecipientTag
125125 -- ^ The header type to use for the recipient.
126126 -- defaults to "to" if not provided
127127 } deriving Show
@@ -196,7 +196,7 @@ deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''MandrillMergeVars
196196
197197--------------------------------------------------------------------------------
198198data MandrillMetadata = MandrillMetadata {
199− _mmdt_rcpt :: !T.Text
199+ _mmdt_rcpt :: !T.Text
200200 , _mmdt_values :: Object
201201 } deriving Show
202202
@@ -221,8 +221,8 @@ instance FromJSON Base64ByteString where
221221
222222--------------------------------------------------------------------------------
223223data MandrillWebContent = MandrillWebContent {
224− _mwct_type :: !T.Text
225− , _mwct_name :: !T.Text
224+ _mwct_type :: !T.Text
225+ , _mwct_name :: !T.Text
226226 -- ^ [for images] the Content ID of the image
227227 -- - use <img src="cid:THIS_VALUE"> to reference the image
228228 -- in your HTML content
@@ -235,67 +235,67 @@ deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''MandrillWebContent
235235--------------------------------------------------------------------------------
236236-- | The information on the message to send
237237data MandrillMessage = MandrillMessage {
238− _mmsg_html :: MandrillHtml
238+ _mmsg_html :: MandrillHtml
239239 -- ^ The full HTML content to be sent
240− , _mmsg_text :: Maybe T.Text
240+ , _mmsg_text :: Maybe T.Text
241241 -- ^ Optional full text content to be sent
242− , _mmsg_subject :: !T.Text
242+ , _mmsg_subject :: !T.Text
243243 -- ^ The message subject
244− , _mmsg_from_email :: MandrillEmail
244+ , _mmsg_from_email :: MandrillEmail
245245 -- ^ The sender email address
246− , _mmsg_from_name :: Maybe T.Text
246+ , _mmsg_from_name :: Maybe T.Text
247247 -- ^ Optional from name to be used
248− , _mmsg_to :: [MandrillRecipient]
248+ , _mmsg_to :: [MandrillRecipient]
249249 -- ^ A list of recipient information
250− , _mmsg_headers :: MandrillHeaders
250+ , _mmsg_headers :: MandrillHeaders
251251 -- ^ optional extra headers to add to the message (most headers are allowed)
252− , _mmsg_important :: Maybe Bool
252+ , _mmsg_important :: Maybe Bool
253253 -- ^ whether or not this message is important, and should be delivered ahead
254254 -- of non-important messages
255− , _mmsg_track_opens :: Maybe Bool
255+ , _mmsg_track_opens :: Maybe Bool
256256 -- ^ whether or not to turn on open tracking for the message
257− , _mmsg_track_clicks :: Maybe Bool
257+ , _mmsg_track_clicks :: Maybe Bool
258258 -- ^ whether or not to turn on click tracking for the message
259− , _mmsg_auto_text :: Maybe Bool
259+ , _mmsg_auto_text :: Maybe Bool
260260 -- ^ whether or not to automatically generate a text part for messages that are not given text
261− , _mmsg_auto_html :: Maybe Bool
261+ , _mmsg_auto_html :: Maybe Bool
262262 -- ^ whether or not to automatically generate an HTML part for messages that are not given HTML
263− , _mmsg_inline_css :: Maybe Bool
263+ , _mmsg_inline_css :: Maybe Bool
264264 -- ^ whether or not to automatically inline all CSS styles provided in the message HTML
265265 -- - only for HTML documents less than 256KB in size
266− , _mmsg_url_strip_qs :: Maybe Bool
266+ , _mmsg_url_strip_qs :: Maybe Bool
267267 -- ^ whether or not to strip the query string from URLs when aggregating tracked URL data
268− , _mmsg_preserve_recipients :: Maybe Bool
268+ , _mmsg_preserve_recipients :: Maybe Bool
269269 -- ^ whether or not to expose all recipients in to "To" header for each email
270− , _mmsg_view_content_link :: Maybe Bool
270+ , _mmsg_view_content_link :: Maybe Bool
271271 -- ^ set to false to remove content logging for sensitive emails
272− , _mmsg_bcc_address :: Maybe T.Text
272+ , _mmsg_bcc_address :: Maybe T.Text
273273 -- ^ an optional address to receive an exact copy of each recipient's email
274− , _mmsg_tracking_domain :: Maybe T.Text
274+ , _mmsg_tracking_domain :: Maybe T.Text
275275 -- ^ a custom domain to use for tracking opens and clicks instead of mandrillapp.com
276− , _mmsg_signing_domain :: Maybe Bool
276+ , _mmsg_signing_domain :: Maybe Bool
277277 -- ^ a custom domain to use for SPF/DKIM signing instead of mandrill
278278 -- (for "via" or "on behalf of" in email clients)
279− , _mmsg_return_path_domain :: Maybe Bool
279+ , _mmsg_return_path_domain :: Maybe Bool
280280 -- ^ a custom domain to use for the messages's return-path
281− , _mmsg_merge :: Maybe Bool
281+ , _mmsg_merge :: Maybe Bool
282282 -- ^ whether to evaluate merge tags in the message.
283283 -- Will automatically be set to true if either merge_vars
284284 -- or global_merge_vars are provided.
285− , _mmsg_global_merge_vars :: [MergeVar]
285+ , _mmsg_global_merge_vars :: [MergeVar]
286286 -- ^ global merge variables to use for all recipients. You can override these per recipient.
287− , _mmsg_merge_vars :: [MandrillMergeVars]
287+ , _mmsg_merge_vars :: [MandrillMergeVars]
288288 -- ^ per-recipient merge variables, which override global merge variables with the same name.
289− , _mmsg_tags :: [MandrillTags]
289+ , _mmsg_tags :: [MandrillTags]
290290 -- ^ an array of string to tag the message with. Stats are accumulated using tags,
291291 -- though we only store the first 100 we see, so this should not be unique
292292 -- or change frequently. Tags should be 50 characters or less.
293293 -- Any tags starting with an underscore are reserved for internal use
294294 -- and will cause errors.
295− , _mmsg_subaccount :: Maybe T.Text
295+ , _mmsg_subaccount :: Maybe T.Text
296296 -- ^ the unique id of a subaccount for this message
297297 -- - must already exist or will fail with an error
298− , _mmsg_google_analytics_domains :: [T.Text]
298+ , _mmsg_google_analytics_domains :: [T.Text]
299299 -- ^ an array of strings indicating for which any matching URLs
300300 -- will automatically have Google Analytics parameters appended
301301 -- to their query string automatically.
@@ -303,17 +303,17 @@ data MandrillMessage = MandrillMessage {
303303 -- ^ optional string indicating the value to set for the utm_campaign
304304 -- tracking parameter. If this isn't provided the email's from address
305305 -- will be used instead.
306− , _mmsg_metadata :: Object
306+ , _mmsg_metadata :: Object
307307 -- ^ metadata an associative array of user metadata. Mandrill will store
308308 -- this metadata and make it available for retrieval.
309309 -- In addition, you can select up to 10 metadata fields to index
310310 -- and make searchable using the Mandrill search api.
311− , _mmsg_recipient_metadata :: [MandrillMetadata]
311+ , _mmsg_recipient_metadata :: [MandrillMetadata]
312312 -- ^ Per-recipient metadata that will override the global values
313313 -- specified in the metadata parameter.
314− , _mmsg_attachments :: [MandrillWebContent]
314+ , _mmsg_attachments :: [MandrillWebContent]
315315 -- ^ an array of supported attachments to add to the message
316− , _mmsg_images :: [MandrillWebContent]
316+ , _mmsg_images :: [MandrillWebContent]
317317 -- ^ an array of embedded images to add to the message
318318 } deriving Show
319319
test/Main.hs+11−7
@@ -1,14 +1,14 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Main where
33
4−import System.Environment
54import Data.Monoid
6−import Tests
5+import qualified Data.Text as T
76import Online
7+import System.Environment
88import Test.Tasty
99import Test.Tasty.HUnit
1010import Test.Tasty.QuickCheck
11−import qualified Data.Text as T
11+import Tests
1212
1313----------------------------------------------------------------------
1414withQuickCheckDepth :: TestName -> Int -> [TestTree] -> TestTree
@@ -23,10 +23,12 @@ onlineTestsIfEnabled = do
2323 Nothing -> return []
2424 Just k -> return [
2525 testGroup "Mandrill online tests" [
26− testCase "users/info.json" (testOnlineUsersInfo k)
27− , testCase "users/ping2.json" (testOnlineUsersPing2 k)
28− , testCase "users/senders.json" (testOnlineUsersSenders k)
29− , testCase "messages/send.json" (testOnlineMessagesSend k)
26+ testCase "users/info.json" (testOnlineUsersInfo k)
27+ , testCase "users/ping2.json" (testOnlineUsersPing2 k)
28+ , testCase "users/senders.json" (testOnlineUsersSenders k)
29+ , testCase "messages/send.json" (testOnlineMessagesSend k)
30+ , testCase "inbound/addDomain.json" (testOnlineDomainAdd k)
31+ , testCase "inbound/addRoute.json" (testOnlineRouteAdd k)
3032 ]]
3133
3234----------------------------------------------------------------------
@@ -40,5 +42,7 @@ main = do
4042 , testCase "users/senders.json API parsing" testUsersSenders
4143 , testCase "messages/send.json API parsing" testMessagesSend
4244 , testCase "messages/send.json API response parsing" testMessagesResponseRejected
45+ , testCase "inbound/add-route.json API response parsing" testRouteAdd
46+ , testCase "inbound/add-domain.json API response parsing" testDomainAdd
4347 ]
4448 ]
test/Online.hs+25−7
@@ -1,19 +1,20 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Online where
33
4−import Test.QuickCheck
5−import Test.Tasty.HUnit
6−import Text.RawString.QQ
7−import Data.Either
84import Data.Aeson
5+import qualified Data.ByteString.Char8 as C8
6+import Data.Either
97import Network.API.Mandrill.Messages.Types
108import Network.API.Mandrill.Users.Types
11−import qualified Data.ByteString.Char8 as C8
129import RawData
10+import Test.QuickCheck
11+import Test.Tasty.HUnit
12+import Text.RawString.QQ
1313
14+import qualified Network.API.Mandrill.Inbound as API
15+import qualified Network.API.Mandrill.Messages as API
1416import Network.API.Mandrill.Types
15−import qualified Network.API.Mandrill.Messages as API
16−import qualified Network.API.Mandrill.Users as API
17+import qualified Network.API.Mandrill.Users as API
1718
1819--
1920-- Users calls
@@ -50,3 +51,20 @@ testOnlineMessagesSend k = do
5051 case res of
5152 MandrillSuccess _ -> return ()
5253 MandrillFailure e -> fail $ "messages/send.json " ++ show e
54+
55+--
56+-- Inbound calls
57+--
58+
59+testOnlineDomainAdd k = do
60+ res <- API.addDomain k "foobar.com" Nothing
61+ case res of
62+ MandrillSuccess a -> print a
63+ MandrillFailure e -> fail $ "inbound/add-domain.json " ++ show e
64+
65+
66+testOnlineRouteAdd k = do
67+ res <- API.addRoute k "foobar.com" "mail-*" "http://requestb.in/19a4frw1" Nothing
68+ case res of
69+ MandrillSuccess a -> print a
70+ MandrillFailure e -> fail $ "inbound/add-domain.json " ++ show e
test/RawData.hs+22−4
@@ -1,10 +1,10 @@
11{-# LANGUAGE QuasiQuotes #-}
22module RawData where
33
4−import Test.QuickCheck
5−import Test.Tasty.HUnit
6−import Text.RawString.QQ
7−import Data.Either
4+import Data.Either
5+import Test.QuickCheck
6+import Test.Tasty.HUnit
7+import Text.RawString.QQ
88
99usersInfoData :: String
1010usersInfoData = [r|
@@ -210,3 +210,21 @@ messagesResponseRejected = [r|
210210 }
211211]
212212|]
213+
214+
215+domainAdd = [r|
216+{
217+ "domain": "inbound.example.com",
218+ "created_at": "2013-01-01 15:30:27",
219+ "valid_mx": true
220+}
221+|]
222+
223+
224+routeAdd= [r|
225+{
226+ "id": "7.23",
227+ "pattern": "mailbox-*",
228+ "url": "http://example.com/webhook-url"
229+}
230+|]
test/Tests.hs+20−2
@@ -4,9 +4,10 @@ module Tests where
44import Data.Aeson
55import qualified Data.ByteString.Char8 as C8
66import Data.Either
7+import Network.API.Mandrill.Inbound
78import Network.API.Mandrill.Messages.Types
8−import Network.API.Mandrill.Users.Types
99import Network.API.Mandrill.Types
10+import Network.API.Mandrill.Users.Types
1011import RawData
1112import Test.Tasty.HUnit
1213
@@ -17,7 +18,7 @@ isRight _ = True
1718#endif
1819
1920testMessagesSend :: Assertion
20−testMessagesSend =
21+testMessagesSend =
2122 assertBool ("send.json: Parsing failed! " ++ show parsePayload)
2223 (isRight parsePayload)
2324 where
@@ -49,3 +50,20 @@ testMessagesResponseRejected = do
4950 where
5051 parsePayload :: Either String (MandrillResponse [MessagesResponse])
5152 parsePayload = eitherDecodeStrict . C8.pack $ messagesResponseRejected
53+
54+testDomainAdd :: Assertion
55+testDomainAdd =
56+ assertBool ("inbound/add-domain.json (response): parsing failed" ++ show parsePayload)
57+ (isRight parsePayload)
58+ where
59+ parsePayload :: Either String DomainAddResponse
60+ parsePayload = eitherDecodeStrict . C8.pack $ domainAdd
61+
62+
63+testRouteAdd :: Assertion
64+testRouteAdd =
65+ assertBool ("inbound/add-route.json (response): parsing failed" ++ show parsePayload)
66+ (isRight parsePayload)
67+ where
68+ parsePayload :: Either String RouteAddResponse
69+ parsePayload = eitherDecodeStrict . C8.pack $ routeAdd