{-# 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.CognitoIdentityProvider.Types.MessageTemplateType
-- 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.CognitoIdentityProvider.Types.MessageTemplateType where

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

-- | The message template structure.
--
-- /See:/ 'newMessageTemplateType' smart constructor.
data MessageTemplateType = MessageTemplateType'
  { -- | The subject line for email messages. EmailSubject is allowed only if
    -- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_EmailConfigurationType.html#CognitoUserPools-Type-EmailConfigurationType-EmailSendingAccount EmailSendingAccount>
    -- is DEVELOPER.
    MessageTemplateType -> Maybe Text
emailSubject :: Prelude.Maybe Prelude.Text,
    -- | The message template for SMS messages.
    MessageTemplateType -> Maybe Text
sMSMessage :: Prelude.Maybe Prelude.Text,
    -- | The message template for email messages. EmailMessage is allowed only if
    -- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_EmailConfigurationType.html#CognitoUserPools-Type-EmailConfigurationType-EmailSendingAccount EmailSendingAccount>
    -- is DEVELOPER.
    MessageTemplateType -> Maybe Text
emailMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (MessageTemplateType -> MessageTemplateType -> Bool
(MessageTemplateType -> MessageTemplateType -> Bool)
-> (MessageTemplateType -> MessageTemplateType -> Bool)
-> Eq MessageTemplateType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageTemplateType -> MessageTemplateType -> Bool
$c/= :: MessageTemplateType -> MessageTemplateType -> Bool
== :: MessageTemplateType -> MessageTemplateType -> Bool
$c== :: MessageTemplateType -> MessageTemplateType -> Bool
Prelude.Eq, ReadPrec [MessageTemplateType]
ReadPrec MessageTemplateType
Int -> ReadS MessageTemplateType
ReadS [MessageTemplateType]
(Int -> ReadS MessageTemplateType)
-> ReadS [MessageTemplateType]
-> ReadPrec MessageTemplateType
-> ReadPrec [MessageTemplateType]
-> Read MessageTemplateType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageTemplateType]
$creadListPrec :: ReadPrec [MessageTemplateType]
readPrec :: ReadPrec MessageTemplateType
$creadPrec :: ReadPrec MessageTemplateType
readList :: ReadS [MessageTemplateType]
$creadList :: ReadS [MessageTemplateType]
readsPrec :: Int -> ReadS MessageTemplateType
$creadsPrec :: Int -> ReadS MessageTemplateType
Prelude.Read, Int -> MessageTemplateType -> ShowS
[MessageTemplateType] -> ShowS
MessageTemplateType -> String
(Int -> MessageTemplateType -> ShowS)
-> (MessageTemplateType -> String)
-> ([MessageTemplateType] -> ShowS)
-> Show MessageTemplateType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageTemplateType] -> ShowS
$cshowList :: [MessageTemplateType] -> ShowS
show :: MessageTemplateType -> String
$cshow :: MessageTemplateType -> String
showsPrec :: Int -> MessageTemplateType -> ShowS
$cshowsPrec :: Int -> MessageTemplateType -> ShowS
Prelude.Show, (forall x. MessageTemplateType -> Rep MessageTemplateType x)
-> (forall x. Rep MessageTemplateType x -> MessageTemplateType)
-> Generic MessageTemplateType
forall x. Rep MessageTemplateType x -> MessageTemplateType
forall x. MessageTemplateType -> Rep MessageTemplateType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageTemplateType x -> MessageTemplateType
$cfrom :: forall x. MessageTemplateType -> Rep MessageTemplateType x
Prelude.Generic)

-- |
-- Create a value of 'MessageTemplateType' 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:
--
-- 'emailSubject', 'messageTemplateType_emailSubject' - The subject line for email messages. EmailSubject is allowed only if
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_EmailConfigurationType.html#CognitoUserPools-Type-EmailConfigurationType-EmailSendingAccount EmailSendingAccount>
-- is DEVELOPER.
--
-- 'sMSMessage', 'messageTemplateType_sMSMessage' - The message template for SMS messages.
--
-- 'emailMessage', 'messageTemplateType_emailMessage' - The message template for email messages. EmailMessage is allowed only if
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_EmailConfigurationType.html#CognitoUserPools-Type-EmailConfigurationType-EmailSendingAccount EmailSendingAccount>
-- is DEVELOPER.
newMessageTemplateType ::
  MessageTemplateType
newMessageTemplateType :: MessageTemplateType
newMessageTemplateType =
  MessageTemplateType' :: Maybe Text -> Maybe Text -> Maybe Text -> MessageTemplateType
MessageTemplateType'
    { $sel:emailSubject:MessageTemplateType' :: Maybe Text
emailSubject =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sMSMessage:MessageTemplateType' :: Maybe Text
sMSMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:emailMessage:MessageTemplateType' :: Maybe Text
emailMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The subject line for email messages. EmailSubject is allowed only if
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_EmailConfigurationType.html#CognitoUserPools-Type-EmailConfigurationType-EmailSendingAccount EmailSendingAccount>
-- is DEVELOPER.
messageTemplateType_emailSubject :: Lens.Lens' MessageTemplateType (Prelude.Maybe Prelude.Text)
messageTemplateType_emailSubject :: (Maybe Text -> f (Maybe Text))
-> MessageTemplateType -> f MessageTemplateType
messageTemplateType_emailSubject = (MessageTemplateType -> Maybe Text)
-> (MessageTemplateType -> Maybe Text -> MessageTemplateType)
-> Lens
     MessageTemplateType MessageTemplateType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageTemplateType' {Maybe Text
emailSubject :: Maybe Text
$sel:emailSubject:MessageTemplateType' :: MessageTemplateType -> Maybe Text
emailSubject} -> Maybe Text
emailSubject) (\s :: MessageTemplateType
s@MessageTemplateType' {} Maybe Text
a -> MessageTemplateType
s {$sel:emailSubject:MessageTemplateType' :: Maybe Text
emailSubject = Maybe Text
a} :: MessageTemplateType)

-- | The message template for SMS messages.
messageTemplateType_sMSMessage :: Lens.Lens' MessageTemplateType (Prelude.Maybe Prelude.Text)
messageTemplateType_sMSMessage :: (Maybe Text -> f (Maybe Text))
-> MessageTemplateType -> f MessageTemplateType
messageTemplateType_sMSMessage = (MessageTemplateType -> Maybe Text)
-> (MessageTemplateType -> Maybe Text -> MessageTemplateType)
-> Lens
     MessageTemplateType MessageTemplateType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageTemplateType' {Maybe Text
sMSMessage :: Maybe Text
$sel:sMSMessage:MessageTemplateType' :: MessageTemplateType -> Maybe Text
sMSMessage} -> Maybe Text
sMSMessage) (\s :: MessageTemplateType
s@MessageTemplateType' {} Maybe Text
a -> MessageTemplateType
s {$sel:sMSMessage:MessageTemplateType' :: Maybe Text
sMSMessage = Maybe Text
a} :: MessageTemplateType)

-- | The message template for email messages. EmailMessage is allowed only if
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_EmailConfigurationType.html#CognitoUserPools-Type-EmailConfigurationType-EmailSendingAccount EmailSendingAccount>
-- is DEVELOPER.
messageTemplateType_emailMessage :: Lens.Lens' MessageTemplateType (Prelude.Maybe Prelude.Text)
messageTemplateType_emailMessage :: (Maybe Text -> f (Maybe Text))
-> MessageTemplateType -> f MessageTemplateType
messageTemplateType_emailMessage = (MessageTemplateType -> Maybe Text)
-> (MessageTemplateType -> Maybe Text -> MessageTemplateType)
-> Lens
     MessageTemplateType MessageTemplateType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageTemplateType' {Maybe Text
emailMessage :: Maybe Text
$sel:emailMessage:MessageTemplateType' :: MessageTemplateType -> Maybe Text
emailMessage} -> Maybe Text
emailMessage) (\s :: MessageTemplateType
s@MessageTemplateType' {} Maybe Text
a -> MessageTemplateType
s {$sel:emailMessage:MessageTemplateType' :: Maybe Text
emailMessage = Maybe Text
a} :: MessageTemplateType)

instance Core.FromJSON MessageTemplateType where
  parseJSON :: Value -> Parser MessageTemplateType
parseJSON =
    String
-> (Object -> Parser MessageTemplateType)
-> Value
-> Parser MessageTemplateType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MessageTemplateType"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> MessageTemplateType
MessageTemplateType'
            (Maybe Text -> Maybe Text -> Maybe Text -> MessageTemplateType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> MessageTemplateType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EmailSubject")
            Parser (Maybe Text -> Maybe Text -> MessageTemplateType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> MessageTemplateType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SMSMessage")
            Parser (Maybe Text -> MessageTemplateType)
-> Parser (Maybe Text) -> Parser MessageTemplateType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EmailMessage")
      )

instance Prelude.Hashable MessageTemplateType

instance Prelude.NFData MessageTemplateType

instance Core.ToJSON MessageTemplateType where
  toJSON :: MessageTemplateType -> Value
toJSON MessageTemplateType' {Maybe Text
emailMessage :: Maybe Text
sMSMessage :: Maybe Text
emailSubject :: Maybe Text
$sel:emailMessage:MessageTemplateType' :: MessageTemplateType -> Maybe Text
$sel:sMSMessage:MessageTemplateType' :: MessageTemplateType -> Maybe Text
$sel:emailSubject:MessageTemplateType' :: MessageTemplateType -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EmailSubject" 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
emailSubject,
            (Text
"SMSMessage" 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
sMSMessage,
            (Text
"EmailMessage" 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
emailMessage
          ]
      )