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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.JourneyEmailMessage
import qualified Amazonka.Prelude as Prelude

-- | Specifies the settings for an email activity in a journey. This type of
-- activity sends an email message to participants.
--
-- /See:/ 'newEmailMessageActivity' smart constructor.
data EmailMessageActivity = EmailMessageActivity'
  { -- | The name of the email message template to use for the message. If
    -- specified, this value must match the name of an existing message
    -- template.
    EmailMessageActivity -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the version of the email template to use for
    -- the message. If specified, this value must match the identifier for an
    -- existing template version. To retrieve a list of versions and version
    -- identifiers for a template, use the Template Versions resource.
    --
    -- If you don\'t specify a value for this property, Amazon Pinpoint uses
    -- the /active version/ of the template. The /active version/ is typically
    -- the version of a template that\'s been most recently reviewed and
    -- approved for use, depending on your workflow. It isn\'t necessarily the
    -- latest version of a template.
    EmailMessageActivity -> Maybe Text
templateVersion :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the next activity to perform, after the
    -- message is sent.
    EmailMessageActivity -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
    -- | Specifies the sender address for an email message that\'s sent to
    -- participants in the journey.
    EmailMessageActivity -> Maybe JourneyEmailMessage
messageConfig :: Prelude.Maybe JourneyEmailMessage
  }
  deriving (EmailMessageActivity -> EmailMessageActivity -> Bool
(EmailMessageActivity -> EmailMessageActivity -> Bool)
-> (EmailMessageActivity -> EmailMessageActivity -> Bool)
-> Eq EmailMessageActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmailMessageActivity -> EmailMessageActivity -> Bool
$c/= :: EmailMessageActivity -> EmailMessageActivity -> Bool
== :: EmailMessageActivity -> EmailMessageActivity -> Bool
$c== :: EmailMessageActivity -> EmailMessageActivity -> Bool
Prelude.Eq, ReadPrec [EmailMessageActivity]
ReadPrec EmailMessageActivity
Int -> ReadS EmailMessageActivity
ReadS [EmailMessageActivity]
(Int -> ReadS EmailMessageActivity)
-> ReadS [EmailMessageActivity]
-> ReadPrec EmailMessageActivity
-> ReadPrec [EmailMessageActivity]
-> Read EmailMessageActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EmailMessageActivity]
$creadListPrec :: ReadPrec [EmailMessageActivity]
readPrec :: ReadPrec EmailMessageActivity
$creadPrec :: ReadPrec EmailMessageActivity
readList :: ReadS [EmailMessageActivity]
$creadList :: ReadS [EmailMessageActivity]
readsPrec :: Int -> ReadS EmailMessageActivity
$creadsPrec :: Int -> ReadS EmailMessageActivity
Prelude.Read, Int -> EmailMessageActivity -> ShowS
[EmailMessageActivity] -> ShowS
EmailMessageActivity -> String
(Int -> EmailMessageActivity -> ShowS)
-> (EmailMessageActivity -> String)
-> ([EmailMessageActivity] -> ShowS)
-> Show EmailMessageActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmailMessageActivity] -> ShowS
$cshowList :: [EmailMessageActivity] -> ShowS
show :: EmailMessageActivity -> String
$cshow :: EmailMessageActivity -> String
showsPrec :: Int -> EmailMessageActivity -> ShowS
$cshowsPrec :: Int -> EmailMessageActivity -> ShowS
Prelude.Show, (forall x. EmailMessageActivity -> Rep EmailMessageActivity x)
-> (forall x. Rep EmailMessageActivity x -> EmailMessageActivity)
-> Generic EmailMessageActivity
forall x. Rep EmailMessageActivity x -> EmailMessageActivity
forall x. EmailMessageActivity -> Rep EmailMessageActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmailMessageActivity x -> EmailMessageActivity
$cfrom :: forall x. EmailMessageActivity -> Rep EmailMessageActivity x
Prelude.Generic)

-- |
-- Create a value of 'EmailMessageActivity' 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:
--
-- 'templateName', 'emailMessageActivity_templateName' - The name of the email message template to use for the message. If
-- specified, this value must match the name of an existing message
-- template.
--
-- 'templateVersion', 'emailMessageActivity_templateVersion' - The unique identifier for the version of the email template to use for
-- the message. If specified, this value must match the identifier for an
-- existing template version. To retrieve a list of versions and version
-- identifiers for a template, use the Template Versions resource.
--
-- If you don\'t specify a value for this property, Amazon Pinpoint uses
-- the /active version/ of the template. The /active version/ is typically
-- the version of a template that\'s been most recently reviewed and
-- approved for use, depending on your workflow. It isn\'t necessarily the
-- latest version of a template.
--
-- 'nextActivity', 'emailMessageActivity_nextActivity' - The unique identifier for the next activity to perform, after the
-- message is sent.
--
-- 'messageConfig', 'emailMessageActivity_messageConfig' - Specifies the sender address for an email message that\'s sent to
-- participants in the journey.
newEmailMessageActivity ::
  EmailMessageActivity
newEmailMessageActivity :: EmailMessageActivity
newEmailMessageActivity =
  EmailMessageActivity' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe JourneyEmailMessage
-> EmailMessageActivity
EmailMessageActivity'
    { $sel:templateName:EmailMessageActivity' :: Maybe Text
templateName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:templateVersion:EmailMessageActivity' :: Maybe Text
templateVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextActivity:EmailMessageActivity' :: Maybe Text
nextActivity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:messageConfig:EmailMessageActivity' :: Maybe JourneyEmailMessage
messageConfig = Maybe JourneyEmailMessage
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the email message template to use for the message. If
-- specified, this value must match the name of an existing message
-- template.
emailMessageActivity_templateName :: Lens.Lens' EmailMessageActivity (Prelude.Maybe Prelude.Text)
emailMessageActivity_templateName :: (Maybe Text -> f (Maybe Text))
-> EmailMessageActivity -> f EmailMessageActivity
emailMessageActivity_templateName = (EmailMessageActivity -> Maybe Text)
-> (EmailMessageActivity -> Maybe Text -> EmailMessageActivity)
-> Lens
     EmailMessageActivity EmailMessageActivity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailMessageActivity' {Maybe Text
templateName :: Maybe Text
$sel:templateName:EmailMessageActivity' :: EmailMessageActivity -> Maybe Text
templateName} -> Maybe Text
templateName) (\s :: EmailMessageActivity
s@EmailMessageActivity' {} Maybe Text
a -> EmailMessageActivity
s {$sel:templateName:EmailMessageActivity' :: Maybe Text
templateName = Maybe Text
a} :: EmailMessageActivity)

-- | The unique identifier for the version of the email template to use for
-- the message. If specified, this value must match the identifier for an
-- existing template version. To retrieve a list of versions and version
-- identifiers for a template, use the Template Versions resource.
--
-- If you don\'t specify a value for this property, Amazon Pinpoint uses
-- the /active version/ of the template. The /active version/ is typically
-- the version of a template that\'s been most recently reviewed and
-- approved for use, depending on your workflow. It isn\'t necessarily the
-- latest version of a template.
emailMessageActivity_templateVersion :: Lens.Lens' EmailMessageActivity (Prelude.Maybe Prelude.Text)
emailMessageActivity_templateVersion :: (Maybe Text -> f (Maybe Text))
-> EmailMessageActivity -> f EmailMessageActivity
emailMessageActivity_templateVersion = (EmailMessageActivity -> Maybe Text)
-> (EmailMessageActivity -> Maybe Text -> EmailMessageActivity)
-> Lens
     EmailMessageActivity EmailMessageActivity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailMessageActivity' {Maybe Text
templateVersion :: Maybe Text
$sel:templateVersion:EmailMessageActivity' :: EmailMessageActivity -> Maybe Text
templateVersion} -> Maybe Text
templateVersion) (\s :: EmailMessageActivity
s@EmailMessageActivity' {} Maybe Text
a -> EmailMessageActivity
s {$sel:templateVersion:EmailMessageActivity' :: Maybe Text
templateVersion = Maybe Text
a} :: EmailMessageActivity)

-- | The unique identifier for the next activity to perform, after the
-- message is sent.
emailMessageActivity_nextActivity :: Lens.Lens' EmailMessageActivity (Prelude.Maybe Prelude.Text)
emailMessageActivity_nextActivity :: (Maybe Text -> f (Maybe Text))
-> EmailMessageActivity -> f EmailMessageActivity
emailMessageActivity_nextActivity = (EmailMessageActivity -> Maybe Text)
-> (EmailMessageActivity -> Maybe Text -> EmailMessageActivity)
-> Lens
     EmailMessageActivity EmailMessageActivity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailMessageActivity' {Maybe Text
nextActivity :: Maybe Text
$sel:nextActivity:EmailMessageActivity' :: EmailMessageActivity -> Maybe Text
nextActivity} -> Maybe Text
nextActivity) (\s :: EmailMessageActivity
s@EmailMessageActivity' {} Maybe Text
a -> EmailMessageActivity
s {$sel:nextActivity:EmailMessageActivity' :: Maybe Text
nextActivity = Maybe Text
a} :: EmailMessageActivity)

-- | Specifies the sender address for an email message that\'s sent to
-- participants in the journey.
emailMessageActivity_messageConfig :: Lens.Lens' EmailMessageActivity (Prelude.Maybe JourneyEmailMessage)
emailMessageActivity_messageConfig :: (Maybe JourneyEmailMessage -> f (Maybe JourneyEmailMessage))
-> EmailMessageActivity -> f EmailMessageActivity
emailMessageActivity_messageConfig = (EmailMessageActivity -> Maybe JourneyEmailMessage)
-> (EmailMessageActivity
    -> Maybe JourneyEmailMessage -> EmailMessageActivity)
-> Lens
     EmailMessageActivity
     EmailMessageActivity
     (Maybe JourneyEmailMessage)
     (Maybe JourneyEmailMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailMessageActivity' {Maybe JourneyEmailMessage
messageConfig :: Maybe JourneyEmailMessage
$sel:messageConfig:EmailMessageActivity' :: EmailMessageActivity -> Maybe JourneyEmailMessage
messageConfig} -> Maybe JourneyEmailMessage
messageConfig) (\s :: EmailMessageActivity
s@EmailMessageActivity' {} Maybe JourneyEmailMessage
a -> EmailMessageActivity
s {$sel:messageConfig:EmailMessageActivity' :: Maybe JourneyEmailMessage
messageConfig = Maybe JourneyEmailMessage
a} :: EmailMessageActivity)

instance Core.FromJSON EmailMessageActivity where
  parseJSON :: Value -> Parser EmailMessageActivity
parseJSON =
    String
-> (Object -> Parser EmailMessageActivity)
-> Value
-> Parser EmailMessageActivity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EmailMessageActivity"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe JourneyEmailMessage
-> EmailMessageActivity
EmailMessageActivity'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe JourneyEmailMessage
 -> EmailMessageActivity)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe JourneyEmailMessage -> EmailMessageActivity)
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
"TemplateName")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe JourneyEmailMessage -> EmailMessageActivity)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe JourneyEmailMessage -> EmailMessageActivity)
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
"TemplateVersion")
            Parser
  (Maybe Text -> Maybe JourneyEmailMessage -> EmailMessageActivity)
-> Parser (Maybe Text)
-> Parser (Maybe JourneyEmailMessage -> EmailMessageActivity)
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
"NextActivity")
            Parser (Maybe JourneyEmailMessage -> EmailMessageActivity)
-> Parser (Maybe JourneyEmailMessage)
-> Parser EmailMessageActivity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JourneyEmailMessage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MessageConfig")
      )

instance Prelude.Hashable EmailMessageActivity

instance Prelude.NFData EmailMessageActivity

instance Core.ToJSON EmailMessageActivity where
  toJSON :: EmailMessageActivity -> Value
toJSON EmailMessageActivity' {Maybe Text
Maybe JourneyEmailMessage
messageConfig :: Maybe JourneyEmailMessage
nextActivity :: Maybe Text
templateVersion :: Maybe Text
templateName :: Maybe Text
$sel:messageConfig:EmailMessageActivity' :: EmailMessageActivity -> Maybe JourneyEmailMessage
$sel:nextActivity:EmailMessageActivity' :: EmailMessageActivity -> Maybe Text
$sel:templateVersion:EmailMessageActivity' :: EmailMessageActivity -> Maybe Text
$sel:templateName:EmailMessageActivity' :: EmailMessageActivity -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TemplateName" 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
templateName,
            (Text
"TemplateVersion" 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
templateVersion,
            (Text
"NextActivity" 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
nextActivity,
            (Text
"MessageConfig" Text -> JourneyEmailMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (JourneyEmailMessage -> Pair)
-> Maybe JourneyEmailMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JourneyEmailMessage
messageConfig
          ]
      )