@@ -20,6 +20,7 @@ module Network.API.Mandrill (
2020 -- $exampleusage
2121 ) where
2222
23+import Control.Lens
2324import Control.Monad.Reader
2425import qualified Data.Aeson as JSON
2526import qualified Data.HashMap.Strict as H
@@ -106,7 +107,7 @@ newHtmlMessage :: EmailAddress
106107 -- ^ The HTML body
107108 -> MandrillMessage
108109newHtmlMessage f t subj html = let body = mkMandrillHtml html in
109− (emptyMessage f t) { _mmsg_html = body, _mmsg_subject = subj }
110+ ((mmsg_html .~ body) . (mmsg_subject .~ subj)) $ (emptyMessage f t)
110111
111112--------------------------------------------------------------------------------
112113-- | Create a new template message (no HTML).
@@ -117,7 +118,7 @@ newTemplateMessage :: EmailAddress
117118 -> T.Text
118119 -- ^ Subject
119120 -> MandrillMessage
120−newTemplateMessage f t subj = (emptyMessage f t) { _mmsg_subject = subj }
121+newTemplateMessage f t subj = (mmsg_subject .~ subj) $ (emptyMessage f t)
121122
122123--------------------------------------------------------------------------------
123124-- | Create a new textual message. By default Mandrill doesn't require you
@@ -133,11 +134,9 @@ newTextMessage :: EmailAddress
133134 -- ^ The body, as normal text.
134135 -> MandrillMessage
135136newTextMessage f t subj txt = let body = unsafeMkMandrillHtml txt in
136− (emptyMessage f t) {
137− _mmsg_html = body
138− , _mmsg_text = Just txt
139− , _mmsg_subject = subj
140− }
137+ ((mmsg_html .~ body) .
138+ (mmsg_text .~ Just txt) .
139+ (mmsg_subject .~ subj)) (emptyMessage f t)
141140
142141
143142--------------------------------------------------------------------------------