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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(JourneyEmailMessage -> JourneyEmailMessage -> Bool)
-> (JourneyEmailMessage -> JourneyEmailMessage -> Bool)
-> Eq JourneyEmailMessage
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]
(Int -> ReadS JourneyEmailMessage)
-> ReadS [JourneyEmailMessage]
-> ReadPrec JourneyEmailMessage
-> ReadPrec [JourneyEmailMessage]
-> Read 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
(Int -> JourneyEmailMessage -> ShowS)
-> (JourneyEmailMessage -> String)
-> ([JourneyEmailMessage] -> ShowS)
-> Show JourneyEmailMessage
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. JourneyEmailMessage -> Rep JourneyEmailMessage x)
-> (forall x. Rep JourneyEmailMessage x -> JourneyEmailMessage)
-> Generic JourneyEmailMessage
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' :: Maybe Text -> JourneyEmailMessage
JourneyEmailMessage' {$sel:fromAddress:JourneyEmailMessage' :: Maybe Text
fromAddress = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> JourneyEmailMessage -> f JourneyEmailMessage
journeyEmailMessage_fromAddress = (JourneyEmailMessage -> Maybe Text)
-> (JourneyEmailMessage -> Maybe Text -> JourneyEmailMessage)
-> Lens
     JourneyEmailMessage JourneyEmailMessage (Maybe Text) (Maybe Text)
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 Core.FromJSON JourneyEmailMessage where
  parseJSON :: Value -> Parser JourneyEmailMessage
parseJSON =
    String
-> (Object -> Parser JourneyEmailMessage)
-> Value
-> Parser JourneyEmailMessage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JourneyEmailMessage"
      ( \Object
x ->
          Maybe Text -> JourneyEmailMessage
JourneyEmailMessage'
            (Maybe Text -> JourneyEmailMessage)
-> Parser (Maybe Text) -> Parser JourneyEmailMessage
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
"FromAddress")
      )

instance Prelude.Hashable JourneyEmailMessage

instance Prelude.NFData JourneyEmailMessage

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