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

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

-- | Specifies the settings for an SMS activity in a journey. This type of
-- activity sends a text message to participants.
--
-- /See:/ 'newSMSMessageActivity' smart constructor.
data SMSMessageActivity = SMSMessageActivity'
  { -- | The name of the SMS message template to use for the message. If
    -- specified, this value must match the name of an existing message
    -- template.
    SMSMessageActivity -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the version of the SMS 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.
    SMSMessageActivity -> Maybe Text
templateVersion :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the next activity to perform, after the
    -- message is sent.
    SMSMessageActivity -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
    -- | Specifies the sender ID and message type for an SMS message that\'s sent
    -- to participants in a journey.
    SMSMessageActivity -> Maybe JourneySMSMessage
messageConfig :: Prelude.Maybe JourneySMSMessage
  }
  deriving (SMSMessageActivity -> SMSMessageActivity -> Bool
(SMSMessageActivity -> SMSMessageActivity -> Bool)
-> (SMSMessageActivity -> SMSMessageActivity -> Bool)
-> Eq SMSMessageActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SMSMessageActivity -> SMSMessageActivity -> Bool
$c/= :: SMSMessageActivity -> SMSMessageActivity -> Bool
== :: SMSMessageActivity -> SMSMessageActivity -> Bool
$c== :: SMSMessageActivity -> SMSMessageActivity -> Bool
Prelude.Eq, ReadPrec [SMSMessageActivity]
ReadPrec SMSMessageActivity
Int -> ReadS SMSMessageActivity
ReadS [SMSMessageActivity]
(Int -> ReadS SMSMessageActivity)
-> ReadS [SMSMessageActivity]
-> ReadPrec SMSMessageActivity
-> ReadPrec [SMSMessageActivity]
-> Read SMSMessageActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SMSMessageActivity]
$creadListPrec :: ReadPrec [SMSMessageActivity]
readPrec :: ReadPrec SMSMessageActivity
$creadPrec :: ReadPrec SMSMessageActivity
readList :: ReadS [SMSMessageActivity]
$creadList :: ReadS [SMSMessageActivity]
readsPrec :: Int -> ReadS SMSMessageActivity
$creadsPrec :: Int -> ReadS SMSMessageActivity
Prelude.Read, Int -> SMSMessageActivity -> ShowS
[SMSMessageActivity] -> ShowS
SMSMessageActivity -> String
(Int -> SMSMessageActivity -> ShowS)
-> (SMSMessageActivity -> String)
-> ([SMSMessageActivity] -> ShowS)
-> Show SMSMessageActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SMSMessageActivity] -> ShowS
$cshowList :: [SMSMessageActivity] -> ShowS
show :: SMSMessageActivity -> String
$cshow :: SMSMessageActivity -> String
showsPrec :: Int -> SMSMessageActivity -> ShowS
$cshowsPrec :: Int -> SMSMessageActivity -> ShowS
Prelude.Show, (forall x. SMSMessageActivity -> Rep SMSMessageActivity x)
-> (forall x. Rep SMSMessageActivity x -> SMSMessageActivity)
-> Generic SMSMessageActivity
forall x. Rep SMSMessageActivity x -> SMSMessageActivity
forall x. SMSMessageActivity -> Rep SMSMessageActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SMSMessageActivity x -> SMSMessageActivity
$cfrom :: forall x. SMSMessageActivity -> Rep SMSMessageActivity x
Prelude.Generic)

-- |
-- Create a value of 'SMSMessageActivity' 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', 'sMSMessageActivity_templateName' - The name of the SMS message template to use for the message. If
-- specified, this value must match the name of an existing message
-- template.
--
-- 'templateVersion', 'sMSMessageActivity_templateVersion' - The unique identifier for the version of the SMS 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', 'sMSMessageActivity_nextActivity' - The unique identifier for the next activity to perform, after the
-- message is sent.
--
-- 'messageConfig', 'sMSMessageActivity_messageConfig' - Specifies the sender ID and message type for an SMS message that\'s sent
-- to participants in a journey.
newSMSMessageActivity ::
  SMSMessageActivity
newSMSMessageActivity :: SMSMessageActivity
newSMSMessageActivity =
  SMSMessageActivity' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe JourneySMSMessage
-> SMSMessageActivity
SMSMessageActivity'
    { $sel:templateName:SMSMessageActivity' :: Maybe Text
templateName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:templateVersion:SMSMessageActivity' :: Maybe Text
templateVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextActivity:SMSMessageActivity' :: Maybe Text
nextActivity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:messageConfig:SMSMessageActivity' :: Maybe JourneySMSMessage
messageConfig = Maybe JourneySMSMessage
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The unique identifier for the version of the SMS 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.
sMSMessageActivity_templateVersion :: Lens.Lens' SMSMessageActivity (Prelude.Maybe Prelude.Text)
sMSMessageActivity_templateVersion :: (Maybe Text -> f (Maybe Text))
-> SMSMessageActivity -> f SMSMessageActivity
sMSMessageActivity_templateVersion = (SMSMessageActivity -> Maybe Text)
-> (SMSMessageActivity -> Maybe Text -> SMSMessageActivity)
-> Lens
     SMSMessageActivity SMSMessageActivity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSMessageActivity' {Maybe Text
templateVersion :: Maybe Text
$sel:templateVersion:SMSMessageActivity' :: SMSMessageActivity -> Maybe Text
templateVersion} -> Maybe Text
templateVersion) (\s :: SMSMessageActivity
s@SMSMessageActivity' {} Maybe Text
a -> SMSMessageActivity
s {$sel:templateVersion:SMSMessageActivity' :: Maybe Text
templateVersion = Maybe Text
a} :: SMSMessageActivity)

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

-- | Specifies the sender ID and message type for an SMS message that\'s sent
-- to participants in a journey.
sMSMessageActivity_messageConfig :: Lens.Lens' SMSMessageActivity (Prelude.Maybe JourneySMSMessage)
sMSMessageActivity_messageConfig :: (Maybe JourneySMSMessage -> f (Maybe JourneySMSMessage))
-> SMSMessageActivity -> f SMSMessageActivity
sMSMessageActivity_messageConfig = (SMSMessageActivity -> Maybe JourneySMSMessage)
-> (SMSMessageActivity
    -> Maybe JourneySMSMessage -> SMSMessageActivity)
-> Lens
     SMSMessageActivity
     SMSMessageActivity
     (Maybe JourneySMSMessage)
     (Maybe JourneySMSMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSMessageActivity' {Maybe JourneySMSMessage
messageConfig :: Maybe JourneySMSMessage
$sel:messageConfig:SMSMessageActivity' :: SMSMessageActivity -> Maybe JourneySMSMessage
messageConfig} -> Maybe JourneySMSMessage
messageConfig) (\s :: SMSMessageActivity
s@SMSMessageActivity' {} Maybe JourneySMSMessage
a -> SMSMessageActivity
s {$sel:messageConfig:SMSMessageActivity' :: Maybe JourneySMSMessage
messageConfig = Maybe JourneySMSMessage
a} :: SMSMessageActivity)

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

instance Prelude.Hashable SMSMessageActivity

instance Prelude.NFData SMSMessageActivity

instance Core.ToJSON SMSMessageActivity where
  toJSON :: SMSMessageActivity -> Value
toJSON SMSMessageActivity' {Maybe Text
Maybe JourneySMSMessage
messageConfig :: Maybe JourneySMSMessage
nextActivity :: Maybe Text
templateVersion :: Maybe Text
templateName :: Maybe Text
$sel:messageConfig:SMSMessageActivity' :: SMSMessageActivity -> Maybe JourneySMSMessage
$sel:nextActivity:SMSMessageActivity' :: SMSMessageActivity -> Maybe Text
$sel:templateVersion:SMSMessageActivity' :: SMSMessageActivity -> Maybe Text
$sel:templateName:SMSMessageActivity' :: SMSMessageActivity -> 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 -> JourneySMSMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (JourneySMSMessage -> Pair)
-> Maybe JourneySMSMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JourneySMSMessage
messageConfig
          ]
      )