@@ -1,34 +1,34 @@
1−{-# LANGUAGE TemplateHaskell #-}
1+{-# LANGUAGE CPP #-}
2−{-# LANGUAGE CPP #-}
2+{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE RankNTypes #-}
3+{-# LANGUAGE RankNTypes #-}
4{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE ScopedTypeVariables #-}
5−{-# LANGUAGE OverloadedStrings #-}
5+{-# LANGUAGE TemplateHaskell #-}
6module Network.API.Mandrill.Types where
6module Network.API.Mandrill.Types where
8−import Network.API.Mandrill.Utils
8+import Control.Applicative
10−import Text.Email.Validate
11import Data.Char
9import Data.Char
12import Data.Maybe
10import Data.Maybe
13import Data.Time
11import Data.Time
14−import Control.Applicative
12+import Network.API.Mandrill.Utils
13+import Test.QuickCheck
14+import Text.Email.Validate
15#if MIN_VERSION_time(1,5,0)
15#if MIN_VERSION_time(1,5,0)
16−import Data.Time.Format (TimeLocale, defaultTimeLocale)
16+import Data.Time.Format (TimeLocale, defaultTimeLocale)
18−import System.Locale (TimeLocale, defaultTimeLocale)
18+import System.Locale (TimeLocale, defaultTimeLocale)
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
26import Control.Lens
20import Control.Lens
28import Data.Aeson
21import Data.Aeson
29−import Data.Aeson.Types
30import Data.Aeson.TH
22import Data.Aeson.TH
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
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
31+import qualified Text.Blaze.Html as Blaze
32import qualified Text.Blaze.Html.Renderer.Text as Blaze
32import qualified Text.Blaze.Html.Renderer.Text as Blaze
@@ -41,9 +41,9 @@ timeParse = parseTime
42--------------------------------------------------------------------------------
42--------------------------------------------------------------------------------
43data MandrillError = MandrillError {
43data MandrillError = MandrillError {
44− _merr_status :: !T.Text
44+ _merr_status :: !T.Text
45− , _merr_code :: !Int
45+ , _merr_code :: !Int
46− , _merr_name :: !T.Text
46+ , _merr_name :: !T.Text
47 , _merr_message :: !T.Text
47 , _merr_message :: !T.Text
48 } deriving Show
48 } deriving Show
@@ -119,9 +119,9 @@ instance FromJSON MandrillEmail where
119data MandrillRecipient = MandrillRecipient {
119data MandrillRecipient = MandrillRecipient {
120 _mrec_email :: MandrillEmail
120 _mrec_email :: MandrillEmail
121 -- ^ The email address of the recipient
121 -- ^ The email address of the recipient
122− , _mrec_name :: Maybe T.Text
122+ , _mrec_name :: Maybe T.Text
123 -- ^ The optional display name to use for the recipient
123 -- ^ The optional display name to use for the recipient
124− , _mrec_type :: Maybe MandrillRecipientTag
124+ , _mrec_type :: Maybe MandrillRecipientTag
125 -- ^ The header type to use for the recipient.
125 -- ^ The header type to use for the recipient.
126 -- defaults to "to" if not provided
126 -- defaults to "to" if not provided
127 } deriving Show
127 } deriving Show
@@ -196,7 +196,7 @@ deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''MandrillMergeVars
197--------------------------------------------------------------------------------
197--------------------------------------------------------------------------------
198data MandrillMetadata = MandrillMetadata {
198data MandrillMetadata = MandrillMetadata {
199− _mmdt_rcpt :: !T.Text
199+ _mmdt_rcpt :: !T.Text
200 , _mmdt_values :: Object
200 , _mmdt_values :: Object
201 } deriving Show
201 } deriving Show
@@ -221,8 +221,8 @@ instance FromJSON Base64ByteString where
222--------------------------------------------------------------------------------
222--------------------------------------------------------------------------------
223data MandrillWebContent = MandrillWebContent {
223data MandrillWebContent = MandrillWebContent {
224− _mwct_type :: !T.Text
224+ _mwct_type :: !T.Text
225− , _mwct_name :: !T.Text
225+ , _mwct_name :: !T.Text
226 -- ^ [for images] the Content ID of the image
226 -- ^ [for images] the Content ID of the image
227 -- - use <img src="cid:THIS_VALUE"> to reference the image
227 -- - use <img src="cid:THIS_VALUE"> to reference the image
228 -- in your HTML content
228 -- in your HTML content
@@ -235,67 +235,67 @@ deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''MandrillWebContent
235--------------------------------------------------------------------------------
235--------------------------------------------------------------------------------
236-- | The information on the message to send
236-- | The information on the message to send
237data MandrillMessage = MandrillMessage {
237data MandrillMessage = MandrillMessage {
238− _mmsg_html :: MandrillHtml
238+ _mmsg_html :: MandrillHtml
239 -- ^ The full HTML content to be sent
239 -- ^ The full HTML content to be sent
240− , _mmsg_text :: Maybe T.Text
240+ , _mmsg_text :: Maybe T.Text
241 -- ^ Optional full text content to be sent
241 -- ^ Optional full text content to be sent
242− , _mmsg_subject :: !T.Text
242+ , _mmsg_subject :: !T.Text
243 -- ^ The message subject
243 -- ^ The message subject
244− , _mmsg_from_email :: MandrillEmail
244+ , _mmsg_from_email :: MandrillEmail
245 -- ^ The sender email address
245 -- ^ The sender email address
246− , _mmsg_from_name :: Maybe T.Text
246+ , _mmsg_from_name :: Maybe T.Text
247 -- ^ Optional from name to be used
247 -- ^ Optional from name to be used
248− , _mmsg_to :: [MandrillRecipient]
248+ , _mmsg_to :: [MandrillRecipient]
249 -- ^ A list of recipient information
249 -- ^ A list of recipient information
250− , _mmsg_headers :: MandrillHeaders
250+ , _mmsg_headers :: MandrillHeaders
251 -- ^ optional extra headers to add to the message (most headers are allowed)
251 -- ^ optional extra headers to add to the message (most headers are allowed)
252− , _mmsg_important :: Maybe Bool
252+ , _mmsg_important :: Maybe Bool
253 -- ^ whether or not this message is important, and should be delivered ahead
253 -- ^ whether or not this message is important, and should be delivered ahead
254 -- of non-important messages
254 -- of non-important messages
255− , _mmsg_track_opens :: Maybe Bool
255+ , _mmsg_track_opens :: Maybe Bool
256 -- ^ whether or not to turn on open tracking for the message
256 -- ^ whether or not to turn on open tracking for the message
257− , _mmsg_track_clicks :: Maybe Bool
257+ , _mmsg_track_clicks :: Maybe Bool
258 -- ^ whether or not to turn on click tracking for the message
258 -- ^ whether or not to turn on click tracking for the message
259− , _mmsg_auto_text :: Maybe Bool
259+ , _mmsg_auto_text :: Maybe Bool
260 -- ^ whether or not to automatically generate a text part for messages that are not given text
260 -- ^ 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
262 -- ^ whether or not to automatically generate an HTML part for messages that are not given HTML
262 -- ^ 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
264 -- ^ whether or not to automatically inline all CSS styles provided in the message HTML
264 -- ^ whether or not to automatically inline all CSS styles provided in the message HTML
265 -- - only for HTML documents less than 256KB in size
265 -- - only for HTML documents less than 256KB in size
266− , _mmsg_url_strip_qs :: Maybe Bool
266+ , _mmsg_url_strip_qs :: Maybe Bool
267 -- ^ whether or not to strip the query string from URLs when aggregating tracked URL data
267 -- ^ 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
269 -- ^ whether or not to expose all recipients in to "To" header for each email
269 -- ^ 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
271 -- ^ set to false to remove content logging for sensitive emails
271 -- ^ set to false to remove content logging for sensitive emails
272− , _mmsg_bcc_address :: Maybe T.Text
272+ , _mmsg_bcc_address :: Maybe T.Text
273 -- ^ an optional address to receive an exact copy of each recipient's email
273 -- ^ 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
275 -- ^ a custom domain to use for tracking opens and clicks instead of mandrillapp.com
275 -- ^ 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
277 -- ^ a custom domain to use for SPF/DKIM signing instead of mandrill
277 -- ^ a custom domain to use for SPF/DKIM signing instead of mandrill
278 -- (for "via" or "on behalf of" in email clients)
278 -- (for "via" or "on behalf of" in email clients)
279− , _mmsg_return_path_domain :: Maybe Bool
279+ , _mmsg_return_path_domain :: Maybe Bool
280 -- ^ a custom domain to use for the messages's return-path
280 -- ^ a custom domain to use for the messages's return-path
281− , _mmsg_merge :: Maybe Bool
281+ , _mmsg_merge :: Maybe Bool
282 -- ^ whether to evaluate merge tags in the message.
282 -- ^ whether to evaluate merge tags in the message.
283 -- Will automatically be set to true if either merge_vars
283 -- Will automatically be set to true if either merge_vars
284 -- or global_merge_vars are provided.
284 -- or global_merge_vars are provided.
285− , _mmsg_global_merge_vars :: [MergeVar]
285+ , _mmsg_global_merge_vars :: [MergeVar]
286 -- ^ global merge variables to use for all recipients. You can override these per recipient.
286 -- ^ global merge variables to use for all recipients. You can override these per recipient.
287− , _mmsg_merge_vars :: [MandrillMergeVars]
287+ , _mmsg_merge_vars :: [MandrillMergeVars]
288 -- ^ per-recipient merge variables, which override global merge variables with the same name.
288 -- ^ per-recipient merge variables, which override global merge variables with the same name.
289− , _mmsg_tags :: [MandrillTags]
289+ , _mmsg_tags :: [MandrillTags]
290 -- ^ an array of string to tag the message with. Stats are accumulated using tags,
290 -- ^ an array of string to tag the message with. Stats are accumulated using tags,
291 -- though we only store the first 100 we see, so this should not be unique
291 -- though we only store the first 100 we see, so this should not be unique
292 -- or change frequently. Tags should be 50 characters or less.
292 -- or change frequently. Tags should be 50 characters or less.
293 -- Any tags starting with an underscore are reserved for internal use
293 -- Any tags starting with an underscore are reserved for internal use
294 -- and will cause errors.
294 -- and will cause errors.
295− , _mmsg_subaccount :: Maybe T.Text
295+ , _mmsg_subaccount :: Maybe T.Text
296 -- ^ the unique id of a subaccount for this message
296 -- ^ the unique id of a subaccount for this message
297 -- - must already exist or will fail with an error
297 -- - must already exist or will fail with an error
298− , _mmsg_google_analytics_domains :: [T.Text]
298+ , _mmsg_google_analytics_domains :: [T.Text]
299 -- ^ an array of strings indicating for which any matching URLs
299 -- ^ an array of strings indicating for which any matching URLs
300 -- will automatically have Google Analytics parameters appended
300 -- will automatically have Google Analytics parameters appended
301 -- to their query string automatically.
301 -- to their query string automatically.
@@ -303,17 +303,17 @@ data MandrillMessage = MandrillMessage {
303 -- ^ optional string indicating the value to set for the utm_campaign
303 -- ^ optional string indicating the value to set for the utm_campaign
304 -- tracking parameter. If this isn't provided the email's from address
304 -- tracking parameter. If this isn't provided the email's from address
305 -- will be used instead.
305 -- will be used instead.
306− , _mmsg_metadata :: Object
306+ , _mmsg_metadata :: Object
307 -- ^ metadata an associative array of user metadata. Mandrill will store
307 -- ^ metadata an associative array of user metadata. Mandrill will store
308 -- this metadata and make it available for retrieval.
308 -- this metadata and make it available for retrieval.
309 -- In addition, you can select up to 10 metadata fields to index
309 -- In addition, you can select up to 10 metadata fields to index
310 -- and make searchable using the Mandrill search api.
310 -- and make searchable using the Mandrill search api.
311− , _mmsg_recipient_metadata :: [MandrillMetadata]
311+ , _mmsg_recipient_metadata :: [MandrillMetadata]
312 -- ^ Per-recipient metadata that will override the global values
312 -- ^ Per-recipient metadata that will override the global values
313 -- specified in the metadata parameter.
313 -- specified in the metadata parameter.
314− , _mmsg_attachments :: [MandrillWebContent]
314+ , _mmsg_attachments :: [MandrillWebContent]
315 -- ^ an array of supported attachments to add to the message
315 -- ^ an array of supported attachments to add to the message
316− , _mmsg_images :: [MandrillWebContent]
316+ , _mmsg_images :: [MandrillWebContent]
317 -- ^ an array of embedded images to add to the message
317 -- ^ an array of embedded images to add to the message
318 } deriving Show
318 } deriving Show