{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SESV2.Types.Template
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SESV2.Types.Template where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that defines the email template to use for an email message,
-- and the values to use for any message variables in that template. An
-- /email template/ is a type of message template that contains content
-- that you want to define, save, and reuse in email messages that you
-- send.
--
-- /See:/ 'newTemplate' smart constructor.
data Template = Template'
  { -- | The name of the template. You will refer to this name when you send
    -- email using the @SendTemplatedEmail@ or @SendBulkTemplatedEmail@
    -- operations.
    Template -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the template.
    Template -> Maybe Text
templateArn :: Prelude.Maybe Prelude.Text,
    -- | An object that defines the values to use for message variables in the
    -- template. This object is a set of key-value pairs. Each key defines a
    -- message variable in the template. The corresponding value defines the
    -- value to use for that variable.
    Template -> Maybe Text
templateData :: Prelude.Maybe 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)

-- |
-- Create a value of 'Template' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'templateName', 'template_templateName' - The name of the template. You will refer to this name when you send
-- email using the @SendTemplatedEmail@ or @SendBulkTemplatedEmail@
-- operations.
--
-- 'templateArn', 'template_templateArn' - The Amazon Resource Name (ARN) of the template.
--
-- 'templateData', 'template_templateData' - An object that defines the values to use for message variables in the
-- template. This object is a set of key-value pairs. Each key defines a
-- message variable in the template. The corresponding value defines the
-- value to use for that variable.
newTemplate ::
  Template
newTemplate :: Template
newTemplate =
  Template' :: Maybe Text -> Maybe Text -> Maybe Text -> Template
Template'
    { $sel:templateName:Template' :: Maybe Text
templateName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:templateArn:Template' :: Maybe Text
templateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:templateData:Template' :: Maybe Text
templateData = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the template. You will refer to this name when you send
-- email using the @SendTemplatedEmail@ or @SendBulkTemplatedEmail@
-- operations.
template_templateName :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_templateName :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_templateName = (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
templateName :: Maybe Text
$sel:templateName:Template' :: Template -> Maybe Text
templateName} -> Maybe Text
templateName) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:templateName:Template' :: Maybe Text
templateName = Maybe Text
a} :: Template)

-- | The Amazon Resource Name (ARN) of the template.
template_templateArn :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_templateArn :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_templateArn = (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
templateArn :: Maybe Text
$sel:templateArn:Template' :: Template -> Maybe Text
templateArn} -> Maybe Text
templateArn) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:templateArn:Template' :: Maybe Text
templateArn = Maybe Text
a} :: Template)

-- | An object that defines the values to use for message variables in the
-- template. This object is a set of key-value pairs. Each key defines a
-- message variable in the template. The corresponding value defines the
-- value to use for that variable.
template_templateData :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_templateData :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_templateData = (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
templateData :: Maybe Text
$sel:templateData:Template' :: Template -> Maybe Text
templateData} -> Maybe Text
templateData) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:templateData:Template' :: Maybe Text
templateData = Maybe Text
a} :: Template)

instance Prelude.Hashable Template

instance Prelude.NFData Template

instance Core.ToJSON Template where
  toJSON :: Template -> Value
toJSON Template' {Maybe Text
templateData :: Maybe Text
templateArn :: Maybe Text
templateName :: Maybe Text
$sel:templateData:Template' :: Template -> Maybe Text
$sel:templateArn:Template' :: Template -> Maybe Text
$sel:templateName:Template' :: Template -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TemplateName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
templateName,
            (Text
"TemplateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
templateArn,
            (Text
"TemplateData" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
templateData
          ]
      )