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

-- | Specifies the \"From\" address for an email message that\'s sent to
-- participants in a journey.
--
-- /See:/ 'newJourneyEmailMessage' smart constructor.
data JourneyEmailMessage = JourneyEmailMessage'
  { -- | The verified email address to send the email message from. The default
    -- address is the FromAddress specified for the email channel for the
    -- application.
    JourneyEmailMessage -> Maybe Text
fromAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (JourneyEmailMessage -> JourneyEmailMessage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JourneyEmailMessage -> JourneyEmailMessage -> Bool
$c/= :: JourneyEmailMessage -> JourneyEmailMessage -> Bool
== :: JourneyEmailMessage -> JourneyEmailMessage -> Bool
$c== :: JourneyEmailMessage -> JourneyEmailMessage -> Bool
Prelude.Eq, ReadPrec [JourneyEmailMessage]
ReadPrec JourneyEmailMessage
Int -> ReadS JourneyEmailMessage
ReadS [JourneyEmailMessage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JourneyEmailMessage]
$creadListPrec :: ReadPrec [JourneyEmailMessage]
readPrec :: ReadPrec JourneyEmailMessage
$creadPrec :: ReadPrec JourneyEmailMessage
readList :: ReadS [JourneyEmailMessage]
$creadList :: ReadS [JourneyEmailMessage]
readsPrec :: Int -> ReadS JourneyEmailMessage
$creadsPrec :: Int -> ReadS JourneyEmailMessage
Prelude.Read, Int -> JourneyEmailMessage -> ShowS
[JourneyEmailMessage] -> ShowS
JourneyEmailMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JourneyEmailMessage] -> ShowS
$cshowList :: [JourneyEmailMessage] -> ShowS
show :: JourneyEmailMessage -> String
$cshow :: JourneyEmailMessage -> String
showsPrec :: Int -> JourneyEmailMessage -> ShowS
$cshowsPrec :: Int -> JourneyEmailMessage -> ShowS
Prelude.Show, forall x. Rep JourneyEmailMessage x -> JourneyEmailMessage
forall x. JourneyEmailMessage -> Rep JourneyEmailMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JourneyEmailMessage x -> JourneyEmailMessage
$cfrom :: forall x. JourneyEmailMessage -> Rep JourneyEmailMessage x
Prelude.Generic)

-- |
-- Create a value of 'JourneyEmailMessage' 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:
--
-- 'fromAddress', 'journeyEmailMessage_fromAddress' - The verified email address to send the email message from. The default
-- address is the FromAddress specified for the email channel for the
-- application.
newJourneyEmailMessage ::
  JourneyEmailMessage
newJourneyEmailMessage :: JourneyEmailMessage
newJourneyEmailMessage =
  JourneyEmailMessage' {$sel:fromAddress:JourneyEmailMessage' :: Maybe Text
fromAddress = forall a. Maybe a
Prelude.Nothing}

-- | The verified email address to send the email message from. The default
-- address is the FromAddress specified for the email channel for the
-- application.
journeyEmailMessage_fromAddress :: Lens.Lens' JourneyEmailMessage (Prelude.Maybe Prelude.Text)
journeyEmailMessage_fromAddress :: Lens' JourneyEmailMessage (Maybe Text)
journeyEmailMessage_fromAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneyEmailMessage' {Maybe Text
fromAddress :: Maybe Text
$sel:fromAddress:JourneyEmailMessage' :: JourneyEmailMessage -> Maybe Text
fromAddress} -> Maybe Text
fromAddress) (\s :: JourneyEmailMessage
s@JourneyEmailMessage' {} Maybe Text
a -> JourneyEmailMessage
s {$sel:fromAddress:JourneyEmailMessage' :: Maybe Text
fromAddress = Maybe Text
a} :: JourneyEmailMessage)

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

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

instance Prelude.NFData JourneyEmailMessage where
  rnf :: JourneyEmailMessage -> ()
rnf JourneyEmailMessage' {Maybe Text
fromAddress :: Maybe Text
$sel:fromAddress:JourneyEmailMessage' :: JourneyEmailMessage -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fromAddress

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