@@ -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