{-# 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.IoTEvents.Types.EmailContent
-- 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.IoTEvents.Types.EmailContent 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

-- | Contains the subject and message of an email.
--
-- /See:/ 'newEmailContent' smart constructor.
data EmailContent = EmailContent'
  { -- | The message that you want to send. The message can be up to 200
    -- characters.
    EmailContent -> Maybe Text
additionalMessage :: Prelude.Maybe Prelude.Text,
    -- | The subject of the email.
    EmailContent -> Maybe Text
subject :: Prelude.Maybe Prelude.Text
  }
  deriving (EmailContent -> EmailContent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmailContent -> EmailContent -> Bool
$c/= :: EmailContent -> EmailContent -> Bool
== :: EmailContent -> EmailContent -> Bool
$c== :: EmailContent -> EmailContent -> Bool
Prelude.Eq, ReadPrec [EmailContent]
ReadPrec EmailContent
Int -> ReadS EmailContent
ReadS [EmailContent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EmailContent]
$creadListPrec :: ReadPrec [EmailContent]
readPrec :: ReadPrec EmailContent
$creadPrec :: ReadPrec EmailContent
readList :: ReadS [EmailContent]
$creadList :: ReadS [EmailContent]
readsPrec :: Int -> ReadS EmailContent
$creadsPrec :: Int -> ReadS EmailContent
Prelude.Read, Int -> EmailContent -> ShowS
[EmailContent] -> ShowS
EmailContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmailContent] -> ShowS
$cshowList :: [EmailContent] -> ShowS
show :: EmailContent -> String
$cshow :: EmailContent -> String
showsPrec :: Int -> EmailContent -> ShowS
$cshowsPrec :: Int -> EmailContent -> ShowS
Prelude.Show, forall x. Rep EmailContent x -> EmailContent
forall x. EmailContent -> Rep EmailContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmailContent x -> EmailContent
$cfrom :: forall x. EmailContent -> Rep EmailContent x
Prelude.Generic)

-- |
-- Create a value of 'EmailContent' 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:
--
-- 'additionalMessage', 'emailContent_additionalMessage' - The message that you want to send. The message can be up to 200
-- characters.
--
-- 'subject', 'emailContent_subject' - The subject of the email.
newEmailContent ::
  EmailContent
newEmailContent :: EmailContent
newEmailContent =
  EmailContent'
    { $sel:additionalMessage:EmailContent' :: Maybe Text
additionalMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:subject:EmailContent' :: Maybe Text
subject = forall a. Maybe a
Prelude.Nothing
    }

-- | The message that you want to send. The message can be up to 200
-- characters.
emailContent_additionalMessage :: Lens.Lens' EmailContent (Prelude.Maybe Prelude.Text)
emailContent_additionalMessage :: Lens' EmailContent (Maybe Text)
emailContent_additionalMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailContent' {Maybe Text
additionalMessage :: Maybe Text
$sel:additionalMessage:EmailContent' :: EmailContent -> Maybe Text
additionalMessage} -> Maybe Text
additionalMessage) (\s :: EmailContent
s@EmailContent' {} Maybe Text
a -> EmailContent
s {$sel:additionalMessage:EmailContent' :: Maybe Text
additionalMessage = Maybe Text
a} :: EmailContent)

-- | The subject of the email.
emailContent_subject :: Lens.Lens' EmailContent (Prelude.Maybe Prelude.Text)
emailContent_subject :: Lens' EmailContent (Maybe Text)
emailContent_subject = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailContent' {Maybe Text
subject :: Maybe Text
$sel:subject:EmailContent' :: EmailContent -> Maybe Text
subject} -> Maybe Text
subject) (\s :: EmailContent
s@EmailContent' {} Maybe Text
a -> EmailContent
s {$sel:subject:EmailContent' :: Maybe Text
subject = Maybe Text
a} :: EmailContent)

instance Data.FromJSON EmailContent where
  parseJSON :: Value -> Parser EmailContent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EmailContent"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> EmailContent
EmailContent'
            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
"additionalMessage")
            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
"subject")
      )

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

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

instance Data.ToJSON EmailContent where
  toJSON :: EmailContent -> Value
toJSON EmailContent' {Maybe Text
subject :: Maybe Text
additionalMessage :: Maybe Text
$sel:subject:EmailContent' :: EmailContent -> Maybe Text
$sel:additionalMessage:EmailContent' :: EmailContent -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"additionalMessage" 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
additionalMessage,
            (Key
"subject" 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
subject
          ]
      )