{-# 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-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.Pinpoint.Types.TemplateConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | The push notification template to use for the message.
    TemplateConfiguration -> Maybe Template
pushTemplate :: Prelude.Maybe Template,
    -- | The email template to use for the message.
    TemplateConfiguration -> Maybe Template
emailTemplate :: Prelude.Maybe Template
  }
  deriving (TemplateConfiguration -> TemplateConfiguration -> Bool
(TemplateConfiguration -> TemplateConfiguration -> Bool)
-> (TemplateConfiguration -> TemplateConfiguration -> Bool)
-> Eq TemplateConfiguration
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]
(Int -> ReadS TemplateConfiguration)
-> ReadS [TemplateConfiguration]
-> ReadPrec TemplateConfiguration
-> ReadPrec [TemplateConfiguration]
-> Read 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
(Int -> TemplateConfiguration -> ShowS)
-> (TemplateConfiguration -> String)
-> ([TemplateConfiguration] -> ShowS)
-> Show TemplateConfiguration
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. TemplateConfiguration -> Rep TemplateConfiguration x)
-> (forall x. Rep TemplateConfiguration x -> TemplateConfiguration)
-> Generic TemplateConfiguration
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:
--
-- '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.
--
-- 'pushTemplate', 'templateConfiguration_pushTemplate' - The push notification template to use for the message.
--
-- 'emailTemplate', 'templateConfiguration_emailTemplate' - The email template to use for the message.
newTemplateConfiguration ::
  TemplateConfiguration
newTemplateConfiguration :: TemplateConfiguration
newTemplateConfiguration =
  TemplateConfiguration' :: Maybe Template
-> Maybe Template
-> Maybe Template
-> Maybe Template
-> TemplateConfiguration
TemplateConfiguration'
    { $sel:sMSTemplate:TemplateConfiguration' :: Maybe Template
sMSTemplate =
        Maybe Template
forall a. Maybe a
Prelude.Nothing,
      $sel:voiceTemplate:TemplateConfiguration' :: Maybe Template
voiceTemplate = Maybe Template
forall a. Maybe a
Prelude.Nothing,
      $sel:pushTemplate:TemplateConfiguration' :: Maybe Template
pushTemplate = Maybe Template
forall a. Maybe a
Prelude.Nothing,
      $sel:emailTemplate:TemplateConfiguration' :: Maybe Template
emailTemplate = Maybe Template
forall a. Maybe a
Prelude.Nothing
    }

-- | The SMS template to use for the message.
templateConfiguration_sMSTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_sMSTemplate :: (Maybe Template -> f (Maybe Template))
-> TemplateConfiguration -> f TemplateConfiguration
templateConfiguration_sMSTemplate = (TemplateConfiguration -> Maybe Template)
-> (TemplateConfiguration
    -> Maybe Template -> TemplateConfiguration)
-> Lens
     TemplateConfiguration
     TemplateConfiguration
     (Maybe Template)
     (Maybe Template)
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 :: (Maybe Template -> f (Maybe Template))
-> TemplateConfiguration -> f TemplateConfiguration
templateConfiguration_voiceTemplate = (TemplateConfiguration -> Maybe Template)
-> (TemplateConfiguration
    -> Maybe Template -> TemplateConfiguration)
-> Lens
     TemplateConfiguration
     TemplateConfiguration
     (Maybe Template)
     (Maybe Template)
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)

-- | The push notification template to use for the message.
templateConfiguration_pushTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_pushTemplate :: (Maybe Template -> f (Maybe Template))
-> TemplateConfiguration -> f TemplateConfiguration
templateConfiguration_pushTemplate = (TemplateConfiguration -> Maybe Template)
-> (TemplateConfiguration
    -> Maybe Template -> TemplateConfiguration)
-> Lens
     TemplateConfiguration
     TemplateConfiguration
     (Maybe Template)
     (Maybe Template)
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 email template to use for the message.
templateConfiguration_emailTemplate :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_emailTemplate :: (Maybe Template -> f (Maybe Template))
-> TemplateConfiguration -> f TemplateConfiguration
templateConfiguration_emailTemplate = (TemplateConfiguration -> Maybe Template)
-> (TemplateConfiguration
    -> Maybe Template -> TemplateConfiguration)
-> Lens
     TemplateConfiguration
     TemplateConfiguration
     (Maybe Template)
     (Maybe Template)
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)

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

instance Prelude.Hashable TemplateConfiguration

instance Prelude.NFData TemplateConfiguration

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