{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.SES.Types.Template where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Template = Template'
{
Template -> Maybe Text
textPart :: Prelude.Maybe Prelude.Text,
Template -> Maybe Text
subjectPart :: Prelude.Maybe Prelude.Text,
Template -> Maybe Text
htmlPart :: Prelude.Maybe Prelude.Text,
Template -> Text
templateName :: Prelude.Text
}
deriving (Template -> Template -> Bool
(Template -> Template -> Bool)
-> (Template -> Template -> Bool) -> Eq Template
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Template -> Template -> Bool
$c/= :: Template -> Template -> Bool
== :: Template -> Template -> Bool
$c== :: Template -> Template -> Bool
Prelude.Eq, ReadPrec [Template]
ReadPrec Template
Int -> ReadS Template
ReadS [Template]
(Int -> ReadS Template)
-> ReadS [Template]
-> ReadPrec Template
-> ReadPrec [Template]
-> Read Template
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Template]
$creadListPrec :: ReadPrec [Template]
readPrec :: ReadPrec Template
$creadPrec :: ReadPrec Template
readList :: ReadS [Template]
$creadList :: ReadS [Template]
readsPrec :: Int -> ReadS Template
$creadsPrec :: Int -> ReadS Template
Prelude.Read, Int -> Template -> ShowS
[Template] -> ShowS
Template -> String
(Int -> Template -> ShowS)
-> (Template -> String) -> ([Template] -> ShowS) -> Show Template
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Template] -> ShowS
$cshowList :: [Template] -> ShowS
show :: Template -> String
$cshow :: Template -> String
showsPrec :: Int -> Template -> ShowS
$cshowsPrec :: Int -> Template -> ShowS
Prelude.Show, (forall x. Template -> Rep Template x)
-> (forall x. Rep Template x -> Template) -> Generic Template
forall x. Rep Template x -> Template
forall x. Template -> Rep Template x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Template x -> Template
$cfrom :: forall x. Template -> Rep Template x
Prelude.Generic)
newTemplate ::
Prelude.Text ->
Template
newTemplate :: Text -> Template
newTemplate Text
pTemplateName_ =
Template' :: Maybe Text -> Maybe Text -> Maybe Text -> Text -> Template
Template'
{ $sel:textPart:Template' :: Maybe Text
textPart = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:subjectPart:Template' :: Maybe Text
subjectPart = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:htmlPart:Template' :: Maybe Text
htmlPart = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:templateName:Template' :: Text
templateName = Text
pTemplateName_
}
template_textPart :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_textPart :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_textPart = (Template -> Maybe Text)
-> (Template -> Maybe Text -> Template)
-> Lens Template Template (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe Text
textPart :: Maybe Text
$sel:textPart:Template' :: Template -> Maybe Text
textPart} -> Maybe Text
textPart) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:textPart:Template' :: Maybe Text
textPart = Maybe Text
a} :: Template)
template_subjectPart :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_subjectPart :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_subjectPart = (Template -> Maybe Text)
-> (Template -> Maybe Text -> Template)
-> Lens Template Template (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe Text
subjectPart :: Maybe Text
$sel:subjectPart:Template' :: Template -> Maybe Text
subjectPart} -> Maybe Text
subjectPart) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:subjectPart:Template' :: Maybe Text
subjectPart = Maybe Text
a} :: Template)
template_htmlPart :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_htmlPart :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_htmlPart = (Template -> Maybe Text)
-> (Template -> Maybe Text -> Template)
-> Lens Template Template (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe Text
htmlPart :: Maybe Text
$sel:htmlPart:Template' :: Template -> Maybe Text
htmlPart} -> Maybe Text
htmlPart) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:htmlPart:Template' :: Maybe Text
htmlPart = Maybe Text
a} :: Template)
template_templateName :: Lens.Lens' Template Prelude.Text
template_templateName :: (Text -> f Text) -> Template -> f Template
template_templateName = (Template -> Text)
-> (Template -> Text -> Template)
-> Lens Template Template Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Text
templateName :: Text
$sel:templateName:Template' :: Template -> Text
templateName} -> Text
templateName) (\s :: Template
s@Template' {} Text
a -> Template
s {$sel:templateName:Template' :: Text
templateName = Text
a} :: Template)
instance Core.FromXML Template where
parseXML :: [Node] -> Either String Template
parseXML [Node]
x =
Maybe Text -> Maybe Text -> Maybe Text -> Text -> Template
Template'
(Maybe Text -> Maybe Text -> Maybe Text -> Text -> Template)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> Text -> Template)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TextPart")
Either String (Maybe Text -> Maybe Text -> Text -> Template)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Text -> Template)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SubjectPart")
Either String (Maybe Text -> Text -> Template)
-> Either String (Maybe Text) -> Either String (Text -> Template)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HtmlPart")
Either String (Text -> Template)
-> Either String Text -> Either String Template
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"TemplateName")
instance Prelude.Hashable Template
instance Prelude.NFData Template
instance Core.ToQuery Template where
toQuery :: Template -> QueryString
toQuery Template' {Maybe Text
Text
templateName :: Text
htmlPart :: Maybe Text
subjectPart :: Maybe Text
textPart :: Maybe Text
$sel:templateName:Template' :: Template -> Text
$sel:htmlPart:Template' :: Template -> Maybe Text
$sel:subjectPart:Template' :: Template -> Maybe Text
$sel:textPart:Template' :: Template -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"TextPart" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
textPart,
ByteString
"SubjectPart" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
subjectPart,
ByteString
"HtmlPart" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
htmlPart,
ByteString
"TemplateName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
templateName
]