@@ -19,6 +19,7 @@ import System.Locale (TimeLocale, defaultTimeLocale)
1919#endif
2020import qualified Data.ByteString as B
2121import qualified Data.ByteString.Base64 as Base64
22+import qualified Data.HashMap.Strict as H
2223import qualified Data.Text as T
2324import qualified Data.Text.Encoding as TL
2425import qualified Data.Text.Lazy as TL
@@ -170,17 +171,23 @@ type MandrillTags = T.Text
170171
171172
172173--------------------------------------------------------------------------------
173−type MandrillHeaders = Value
174+type MandrillHeaders = Object
174175
175176
176177--------------------------------------------------------------------------------
177−type MandrillVars = Value
178178
179+data MergeVar = MergeVar {
180+ _mv_name :: !T.Text
181+ , _mv_content :: Value
182+ } deriving Show
183+
184+makeLenses ''MergeVar
185+deriveJSON defaultOptions { fieldLabelModifier = drop 4 } ''MergeVar
179186
180187--------------------------------------------------------------------------------
181188data MandrillMergeVars = MandrillMergeVars {
182189 _mmvr_rcpt :: !T.Text
183− , _mmvr_vars :: [MandrillVars]
190+ , _mmvr_vars :: [MergeVar]
184191 } deriving Show
185192
186193makeLenses ''MandrillMergeVars
@@ -189,7 +196,7 @@ deriveJSON defaultOptions { fieldLabelModifier = drop 6 } ''MandrillMergeVars
189196--------------------------------------------------------------------------------
190197data MandrillMetadata = MandrillMetadata {
191198 _mmdt_rcpt :: !T.Text
192− , _mmdt_values :: MandrillVars
199+ , _mmdt_values :: Object
193200 } deriving Show
194201
195202makeLenses ''MandrillMetadata
@@ -266,7 +273,7 @@ data MandrillMessage = MandrillMessage {
266273 , _mmsg_tracking_domain :: Maybe T.Text
267274 -- ^ a custom domain to use for tracking opens and clicks instead of mandrillapp.com
268275 , _mmsg_signing_domain :: Maybe Bool
269− -- ^ a custom domain to use for SPF/DKIM signing instead of mandrill
276+ -- ^ a custom domain to use for SPF/DKIM signing instead of mandrill
270277 -- (for "via" or "on behalf of" in email clients)
271278 , _mmsg_return_path_domain :: Maybe Bool
272279 -- ^ a custom domain to use for the messages's return-path
@@ -274,7 +281,7 @@ data MandrillMessage = MandrillMessage {
274281 -- ^ whether to evaluate merge tags in the message.
275282 -- Will automatically be set to true if either merge_vars
276283 -- or global_merge_vars are provided.
277− , _mmsg_global_merge_vars :: [MandrillVars]
284+ , _mmsg_global_merge_vars :: [MergeVar]
278285 -- ^ global merge variables to use for all recipients. You can override these per recipient.
279286 , _mmsg_merge_vars :: [MandrillMergeVars]
280287 -- ^ per-recipient merge variables, which override global merge variables with the same name.
@@ -295,7 +302,7 @@ data MandrillMessage = MandrillMessage {
295302 -- ^ optional string indicating the value to set for the utm_campaign
296303 -- tracking parameter. If this isn't provided the email's from address
297304 -- will be used instead.
298− , _mmsg_metadata :: MandrillVars
305+ , _mmsg_metadata :: Object
299306 -- ^ metadata an associative array of user metadata. Mandrill will store
300307 -- this metadata and make it available for retrieval.
301308 -- In addition, you can select up to 10 metadata fields to index
@@ -319,7 +326,7 @@ instance Arbitrary MandrillMessage where
319326 <*> pure (MandrillEmail . fromJust $ emailAddress "sender@example.com")
320327 <*> pure Nothing
321328 <*> resize 2 arbitrary
322− <*> pure emptyObject
329+ <*> pure H.empty
323330 <*> pure Nothing
324331 <*> pure Nothing
325332 <*> pure Nothing
@@ -340,7 +347,7 @@ instance Arbitrary MandrillMessage where
340347 <*> pure Nothing
341348 <*> pure []
342349 <*> pure Nothing
343− <*> pure emptyObject
350+ <*> pure H.empty
344351 <*> pure []
345352 <*> pure []
346353 <*> pure []