{-# 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.Pinpoint.Types.TemplateConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.TemplateConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.Template
import qualified Amazonka.Prelude as Prelude

-- | Specifies the message template to use for the message, for each type of
-- channel.
--
-- /See:/ 'newTemplateConfiguration' smart constructor.
data TemplateConfiguration = TemplateConfiguration'
  { -- | The email template to use for the message.
    TemplateConfiguration -> Maybe Template
emailTemplate :: Prelude.Maybe Template,
    -- | The push notification template to use for the message.
    TemplateConfiguration -> Maybe Template
pushTemplate :: Prelude.Maybe Template,
    -- | The SMS template to use for the message.
    TemplateConfiguration -> Maybe Template
sMSTemplate :: Prelude.Maybe Template,
    -- | The voice template to use for the message. This object isn\'t supported
    -- for campaigns.
    TemplateConfiguration -> Maybe Template
voiceTemplate :: Prelude.Maybe Template
  }
  deriving (TemplateConfiguration -> TemplateConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplateConfiguration -> TemplateConfiguration -> Bool
$c/= :: TemplateConfiguration -> TemplateConfiguration -> Bool
== :: TemplateConfiguration -> TemplateConfiguration -> Bool
$c== :: TemplateConfiguration -> TemplateConfiguration -> Bool
Prelude.Eq, ReadPrec [TemplateConfiguration]
ReadPrec TemplateConfiguration
Int -> ReadS TemplateConfiguration
ReadS [TemplateConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplateConfiguration]
$creadListPrec :: ReadPrec [TemplateConfiguration]
readPrec :: ReadPrec TemplateConfiguration
$creadPrec :: ReadPrec TemplateConfiguration
readList :: ReadS [TemplateConfiguration]
$creadList :: ReadS [TemplateConfiguration]
readsPrec :: Int -> ReadS TemplateConfiguration
$creadsPrec :: Int -> ReadS TemplateConfiguration
Prelude.Read, Int -> TemplateConfiguration -> ShowS
[TemplateConfiguration] -> ShowS
TemplateConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplateConfiguration] -> ShowS
$cshowList :: [TemplateConfiguration] -> ShowS
show :: TemplateConfiguration -> String
$cshow :: TemplateConfiguration -> String
showsPrec :: Int -> TemplateConfiguration -> ShowS
$cshowsPrec :: Int -> TemplateConfiguration -> ShowS
Prelude.Show, forall x. Rep TemplateConfiguration x -> TemplateConfiguration
forall x. TemplateConfiguration -> Rep TemplateConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TemplateConfiguration x -> TemplateConfiguration
$cfrom :: forall x. TemplateConfiguration -> Rep TemplateConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TemplateConfiguration' 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:
--
-- 'emailTemplate', 'templateConfiguration_emailTemplate' - The email template to use for the message.
--
-- 'pushTemplate', 'templateConfiguration_pushTemplate' - The push notification template to use for the message.
--
-- 'sMSTemplate', 'templateConfiguration_sMSTemplate' - The SMS template to use for the message.
--
-- 'voiceTemplate', 'templateConfiguration_voiceTemplate' - The voice template to use for the message. This object isn\'t supported
-- for campaigns.
newTemplateConfiguration ::
  TemplateConfiguration
newTemplateConfiguration :: TemplateConfiguration
newTemplateConfiguration =
  TemplateConfiguration'
    { $sel:emailTemplate:TemplateConfiguration' :: Maybe Template
emailTemplate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:pushTemplate:TemplateConfiguration' :: Maybe Template
pushTemplate = forall a. Maybe a
Prelude.Nothing,
      $sel:sMSTemplate:TemplateConfiguration' :: Maybe Template
sMSTemplate = forall a. Maybe a
Prelude.Nothing,
      $sel:voiceTemplate:TemplateConfiguration' :: Maybe Template
voiceTemplate = forall a. Maybe a
Prelude.Nothing
    }

-- | The email template to use for the message.
templateConfiguration_emailTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_emailTemplate :: Lens' TemplateConfiguration (Maybe Template)
templateConfiguration_emailTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateConfiguration' {Maybe Template
emailTemplate :: Maybe Template
$sel:emailTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
emailTemplate} -> Maybe Template
emailTemplate) (\s :: TemplateConfiguration
s@TemplateConfiguration' {} Maybe Template
a -> TemplateConfiguration
s {$sel:emailTemplate:TemplateConfiguration' :: Maybe Template
emailTemplate = Maybe Template
a} :: TemplateConfiguration)

-- | The push notification template to use for the message.
templateConfiguration_pushTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_pushTemplate :: Lens' TemplateConfiguration (Maybe Template)
templateConfiguration_pushTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateConfiguration' {Maybe Template
pushTemplate :: Maybe Template
$sel:pushTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
pushTemplate} -> Maybe Template
pushTemplate) (\s :: TemplateConfiguration
s@TemplateConfiguration' {} Maybe Template
a -> TemplateConfiguration
s {$sel:pushTemplate:TemplateConfiguration' :: Maybe Template
pushTemplate = Maybe Template
a} :: TemplateConfiguration)

-- | The SMS template to use for the message.
templateConfiguration_sMSTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_sMSTemplate :: Lens' TemplateConfiguration (Maybe Template)
templateConfiguration_sMSTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateConfiguration' {Maybe Template
sMSTemplate :: Maybe Template
$sel:sMSTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
sMSTemplate} -> Maybe Template
sMSTemplate) (\s :: TemplateConfiguration
s@TemplateConfiguration' {} Maybe Template
a -> TemplateConfiguration
s {$sel:sMSTemplate:TemplateConfiguration' :: Maybe Template
sMSTemplate = Maybe Template
a} :: TemplateConfiguration)

-- | The voice template to use for the message. This object isn\'t supported
-- for campaigns.
templateConfiguration_voiceTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_voiceTemplate :: Lens' TemplateConfiguration (Maybe Template)
templateConfiguration_voiceTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateConfiguration' {Maybe Template
voiceTemplate :: Maybe Template
$sel:voiceTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
voiceTemplate} -> Maybe Template
voiceTemplate) (\s :: TemplateConfiguration
s@TemplateConfiguration' {} Maybe Template
a -> TemplateConfiguration
s {$sel:voiceTemplate:TemplateConfiguration' :: Maybe Template
voiceTemplate = Maybe Template
a} :: TemplateConfiguration)

instance Data.FromJSON TemplateConfiguration where
  parseJSON :: Value -> Parser TemplateConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TemplateConfiguration"
      ( \Object
x ->
          Maybe Template
-> Maybe Template
-> Maybe Template
-> Maybe Template
-> TemplateConfiguration
TemplateConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EmailTemplate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"PushTemplate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SMSTemplate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VoiceTemplate")
      )

instance Prelude.Hashable TemplateConfiguration where
  hashWithSalt :: Int -> TemplateConfiguration -> Int
hashWithSalt Int
_salt TemplateConfiguration' {Maybe Template
voiceTemplate :: Maybe Template
sMSTemplate :: Maybe Template
pushTemplate :: Maybe Template
emailTemplate :: Maybe Template
$sel:voiceTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:sMSTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:pushTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:emailTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Template
emailTemplate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Template
pushTemplate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Template
sMSTemplate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Template
voiceTemplate

instance Prelude.NFData TemplateConfiguration where
  rnf :: TemplateConfiguration -> ()
rnf TemplateConfiguration' {Maybe Template
voiceTemplate :: Maybe Template
sMSTemplate :: Maybe Template
pushTemplate :: Maybe Template
emailTemplate :: Maybe Template
$sel:voiceTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:sMSTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:pushTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:emailTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Template
emailTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Template
pushTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Template
sMSTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Template
voiceTemplate

instance Data.ToJSON TemplateConfiguration where
  toJSON :: TemplateConfiguration -> Value
toJSON TemplateConfiguration' {Maybe Template
voiceTemplate :: Maybe Template
sMSTemplate :: Maybe Template
pushTemplate :: Maybe Template
emailTemplate :: Maybe Template
$sel:voiceTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:sMSTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:pushTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
$sel:emailTemplate:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EmailTemplate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Template
emailTemplate,
            (Key
"PushTemplate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Template
pushTemplate,
            (Key
"SMSTemplate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Template
sMSTemplate,
            (Key
"VoiceTemplate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Template
voiceTemplate
          ]
      )