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

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

-- | The notify email type.
--
-- /See:/ 'newNotifyEmailType' smart constructor.
data NotifyEmailType = NotifyEmailType'
  { -- | The text body.
    NotifyEmailType -> Maybe Text
textBody :: Prelude.Maybe Prelude.Text,
    -- | The HTML body.
    NotifyEmailType -> Maybe Text
htmlBody :: Prelude.Maybe Prelude.Text,
    -- | The subject.
    NotifyEmailType -> Text
subject :: Prelude.Text
  }
  deriving (NotifyEmailType -> NotifyEmailType -> Bool
(NotifyEmailType -> NotifyEmailType -> Bool)
-> (NotifyEmailType -> NotifyEmailType -> Bool)
-> Eq NotifyEmailType
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]
(Int -> ReadS NotifyEmailType)
-> ReadS [NotifyEmailType]
-> ReadPrec NotifyEmailType
-> ReadPrec [NotifyEmailType]
-> Read 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
(Int -> NotifyEmailType -> ShowS)
-> (NotifyEmailType -> String)
-> ([NotifyEmailType] -> ShowS)
-> Show NotifyEmailType
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. NotifyEmailType -> Rep NotifyEmailType x)
-> (forall x. Rep NotifyEmailType x -> NotifyEmailType)
-> Generic NotifyEmailType
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:
--
-- 'textBody', 'notifyEmailType_textBody' - The text body.
--
-- 'htmlBody', 'notifyEmailType_htmlBody' - The HTML body.
--
-- 'subject', 'notifyEmailType_subject' - The subject.
newNotifyEmailType ::
  -- | 'subject'
  Prelude.Text ->
  NotifyEmailType
newNotifyEmailType :: Text -> NotifyEmailType
newNotifyEmailType Text
pSubject_ =
  NotifyEmailType' :: Maybe Text -> Maybe Text -> Text -> NotifyEmailType
NotifyEmailType'
    { $sel:textBody:NotifyEmailType' :: Maybe Text
textBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:htmlBody:NotifyEmailType' :: Maybe Text
htmlBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subject:NotifyEmailType' :: Text
subject = Text
pSubject_
    }

-- | The text body.
notifyEmailType_textBody :: Lens.Lens' NotifyEmailType (Prelude.Maybe Prelude.Text)
notifyEmailType_textBody :: (Maybe Text -> f (Maybe Text))
-> NotifyEmailType -> f NotifyEmailType
notifyEmailType_textBody = (NotifyEmailType -> Maybe Text)
-> (NotifyEmailType -> Maybe Text -> NotifyEmailType)
-> Lens NotifyEmailType NotifyEmailType (Maybe Text) (Maybe Text)
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 HTML body.
notifyEmailType_htmlBody :: Lens.Lens' NotifyEmailType (Prelude.Maybe Prelude.Text)
notifyEmailType_htmlBody :: (Maybe Text -> f (Maybe Text))
-> NotifyEmailType -> f NotifyEmailType
notifyEmailType_htmlBody = (NotifyEmailType -> Maybe Text)
-> (NotifyEmailType -> Maybe Text -> NotifyEmailType)
-> Lens NotifyEmailType NotifyEmailType (Maybe Text) (Maybe Text)
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 subject.
notifyEmailType_subject :: Lens.Lens' NotifyEmailType Prelude.Text
notifyEmailType_subject :: (Text -> f Text) -> NotifyEmailType -> f NotifyEmailType
notifyEmailType_subject = (NotifyEmailType -> Text)
-> (NotifyEmailType -> Text -> NotifyEmailType)
-> Lens NotifyEmailType NotifyEmailType Text Text
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 Core.FromJSON NotifyEmailType where
  parseJSON :: Value -> Parser NotifyEmailType
parseJSON =
    String
-> (Object -> Parser NotifyEmailType)
-> Value
-> Parser NotifyEmailType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NotifyEmailType"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> NotifyEmailType
NotifyEmailType'
            (Maybe Text -> Maybe Text -> Text -> NotifyEmailType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> NotifyEmailType)
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
"TextBody")
            Parser (Maybe Text -> Text -> NotifyEmailType)
-> Parser (Maybe Text) -> Parser (Text -> NotifyEmailType)
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
"HtmlBody")
            Parser (Text -> NotifyEmailType)
-> Parser Text -> Parser NotifyEmailType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Subject")
      )

instance Prelude.Hashable NotifyEmailType

instance Prelude.NFData NotifyEmailType

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