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

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

-- | The notify email type.
--
-- /See:/ 'newNotifyEmailType' smart constructor.
data NotifyEmailType = NotifyEmailType'
  { -- | The email HTML body.
    NotifyEmailType -> Maybe Text
htmlBody :: Prelude.Maybe Prelude.Text,
    -- | The email text body.
    NotifyEmailType -> Maybe Text
textBody :: Prelude.Maybe Prelude.Text,
    -- | The email subject.
    NotifyEmailType -> Text
subject :: Prelude.Text
  }
  deriving (NotifyEmailType -> NotifyEmailType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotifyEmailType -> NotifyEmailType -> Bool
$c/= :: NotifyEmailType -> NotifyEmailType -> Bool
== :: NotifyEmailType -> NotifyEmailType -> Bool
$c== :: NotifyEmailType -> NotifyEmailType -> Bool
Prelude.Eq, ReadPrec [NotifyEmailType]
ReadPrec NotifyEmailType
Int -> ReadS NotifyEmailType
ReadS [NotifyEmailType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotifyEmailType]
$creadListPrec :: ReadPrec [NotifyEmailType]
readPrec :: ReadPrec NotifyEmailType
$creadPrec :: ReadPrec NotifyEmailType
readList :: ReadS [NotifyEmailType]
$creadList :: ReadS [NotifyEmailType]
readsPrec :: Int -> ReadS NotifyEmailType
$creadsPrec :: Int -> ReadS NotifyEmailType
Prelude.Read, Int -> NotifyEmailType -> ShowS
[NotifyEmailType] -> ShowS
NotifyEmailType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotifyEmailType] -> ShowS
$cshowList :: [NotifyEmailType] -> ShowS
show :: NotifyEmailType -> String
$cshow :: NotifyEmailType -> String
showsPrec :: Int -> NotifyEmailType -> ShowS
$cshowsPrec :: Int -> NotifyEmailType -> ShowS
Prelude.Show, forall x. Rep NotifyEmailType x -> NotifyEmailType
forall x. NotifyEmailType -> Rep NotifyEmailType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotifyEmailType x -> NotifyEmailType
$cfrom :: forall x. NotifyEmailType -> Rep NotifyEmailType x
Prelude.Generic)

-- |
-- Create a value of 'NotifyEmailType' 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:
--
-- 'htmlBody', 'notifyEmailType_htmlBody' - The email HTML body.
--
-- 'textBody', 'notifyEmailType_textBody' - The email text body.
--
-- 'subject', 'notifyEmailType_subject' - The email subject.
newNotifyEmailType ::
  -- | 'subject'
  Prelude.Text ->
  NotifyEmailType
newNotifyEmailType :: Text -> NotifyEmailType
newNotifyEmailType Text
pSubject_ =
  NotifyEmailType'
    { $sel:htmlBody:NotifyEmailType' :: Maybe Text
htmlBody = forall a. Maybe a
Prelude.Nothing,
      $sel:textBody:NotifyEmailType' :: Maybe Text
textBody = forall a. Maybe a
Prelude.Nothing,
      $sel:subject:NotifyEmailType' :: Text
subject = Text
pSubject_
    }

-- | The email HTML body.
notifyEmailType_htmlBody :: Lens.Lens' NotifyEmailType (Prelude.Maybe Prelude.Text)
notifyEmailType_htmlBody :: Lens' NotifyEmailType (Maybe Text)
notifyEmailType_htmlBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyEmailType' {Maybe Text
htmlBody :: Maybe Text
$sel:htmlBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
htmlBody} -> Maybe Text
htmlBody) (\s :: NotifyEmailType
s@NotifyEmailType' {} Maybe Text
a -> NotifyEmailType
s {$sel:htmlBody:NotifyEmailType' :: Maybe Text
htmlBody = Maybe Text
a} :: NotifyEmailType)

-- | The email text body.
notifyEmailType_textBody :: Lens.Lens' NotifyEmailType (Prelude.Maybe Prelude.Text)
notifyEmailType_textBody :: Lens' NotifyEmailType (Maybe Text)
notifyEmailType_textBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyEmailType' {Maybe Text
textBody :: Maybe Text
$sel:textBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
textBody} -> Maybe Text
textBody) (\s :: NotifyEmailType
s@NotifyEmailType' {} Maybe Text
a -> NotifyEmailType
s {$sel:textBody:NotifyEmailType' :: Maybe Text
textBody = Maybe Text
a} :: NotifyEmailType)

-- | The email subject.
notifyEmailType_subject :: Lens.Lens' NotifyEmailType Prelude.Text
notifyEmailType_subject :: Lens' NotifyEmailType Text
notifyEmailType_subject = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyEmailType' {Text
subject :: Text
$sel:subject:NotifyEmailType' :: NotifyEmailType -> Text
subject} -> Text
subject) (\s :: NotifyEmailType
s@NotifyEmailType' {} Text
a -> NotifyEmailType
s {$sel:subject:NotifyEmailType' :: Text
subject = Text
a} :: NotifyEmailType)

instance Data.FromJSON NotifyEmailType where
  parseJSON :: Value -> Parser NotifyEmailType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotifyEmailType"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> NotifyEmailType
NotifyEmailType'
            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
"HtmlBody")
            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
"TextBody")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Subject")
      )

instance Prelude.Hashable NotifyEmailType where
  hashWithSalt :: Int -> NotifyEmailType -> Int
hashWithSalt Int
_salt NotifyEmailType' {Maybe Text
Text
subject :: Text
textBody :: Maybe Text
htmlBody :: Maybe Text
$sel:subject:NotifyEmailType' :: NotifyEmailType -> Text
$sel:textBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
$sel:htmlBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
htmlBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
textBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
subject

instance Prelude.NFData NotifyEmailType where
  rnf :: NotifyEmailType -> ()
rnf NotifyEmailType' {Maybe Text
Text
subject :: Text
textBody :: Maybe Text
htmlBody :: Maybe Text
$sel:subject:NotifyEmailType' :: NotifyEmailType -> Text
$sel:textBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
$sel:htmlBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
htmlBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
textBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
subject

instance Data.ToJSON NotifyEmailType where
  toJSON :: NotifyEmailType -> Value
toJSON NotifyEmailType' {Maybe Text
Text
subject :: Text
textBody :: Maybe Text
htmlBody :: Maybe Text
$sel:subject:NotifyEmailType' :: NotifyEmailType -> Text
$sel:textBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
$sel:htmlBody:NotifyEmailType' :: NotifyEmailType -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"HtmlBody" 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 Text
htmlBody,
            (Key
"TextBody" 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 Text
textBody,
            forall a. a -> Maybe a
Prelude.Just (Key
"Subject" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
subject)
          ]
      )