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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.EndpointTypesElement
import Amazonka.Pinpoint.Types.JourneyCustomMessage
import qualified Amazonka.Prelude as Prelude

-- | The settings for a custom message activity. This type of activity calls
-- an AWS Lambda function or web hook that sends messages to participants.
--
-- /See:/ 'newCustomMessageActivity' smart constructor.
data CustomMessageActivity = CustomMessageActivity'
  { -- | The destination to send the campaign or treatment to. This value can be
    -- one of the following:
    --
    -- -   The name or Amazon Resource Name (ARN) of an AWS Lambda function to
    --     invoke to handle delivery of the campaign or treatment.
    --
    -- -   The URL for a web application or service that supports HTTPS and can
    --     receive the message. The URL has to be a full URL, including the
    --     HTTPS protocol.
    CustomMessageActivity -> Maybe Text
deliveryUri :: Prelude.Maybe Prelude.Text,
    -- | The types of endpoints to send the custom message to. Each valid value
    -- maps to a type of channel that you can associate with an endpoint by
    -- using the ChannelType property of an endpoint.
    CustomMessageActivity -> Maybe [EndpointTypesElement]
endpointTypes :: Prelude.Maybe [EndpointTypesElement],
    -- | Specifies the message data included in a custom channel message that\'s
    -- sent to participants in a journey.
    CustomMessageActivity -> Maybe JourneyCustomMessage
messageConfig :: Prelude.Maybe JourneyCustomMessage,
    -- | The unique identifier for the next activity to perform, after Amazon
    -- Pinpoint calls the AWS Lambda function or web hook.
    CustomMessageActivity -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
    -- | The name of the custom message template to use for the message. If
    -- specified, this value must match the name of an existing message
    -- template.
    CustomMessageActivity -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the version of the message 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.
    CustomMessageActivity -> Maybe Text
templateVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (CustomMessageActivity -> CustomMessageActivity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomMessageActivity -> CustomMessageActivity -> Bool
$c/= :: CustomMessageActivity -> CustomMessageActivity -> Bool
== :: CustomMessageActivity -> CustomMessageActivity -> Bool
$c== :: CustomMessageActivity -> CustomMessageActivity -> Bool
Prelude.Eq, ReadPrec [CustomMessageActivity]
ReadPrec CustomMessageActivity
Int -> ReadS CustomMessageActivity
ReadS [CustomMessageActivity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomMessageActivity]
$creadListPrec :: ReadPrec [CustomMessageActivity]
readPrec :: ReadPrec CustomMessageActivity
$creadPrec :: ReadPrec CustomMessageActivity
readList :: ReadS [CustomMessageActivity]
$creadList :: ReadS [CustomMessageActivity]
readsPrec :: Int -> ReadS CustomMessageActivity
$creadsPrec :: Int -> ReadS CustomMessageActivity
Prelude.Read, Int -> CustomMessageActivity -> ShowS
[CustomMessageActivity] -> ShowS
CustomMessageActivity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomMessageActivity] -> ShowS
$cshowList :: [CustomMessageActivity] -> ShowS
show :: CustomMessageActivity -> String
$cshow :: CustomMessageActivity -> String
showsPrec :: Int -> CustomMessageActivity -> ShowS
$cshowsPrec :: Int -> CustomMessageActivity -> ShowS
Prelude.Show, forall x. Rep CustomMessageActivity x -> CustomMessageActivity
forall x. CustomMessageActivity -> Rep CustomMessageActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomMessageActivity x -> CustomMessageActivity
$cfrom :: forall x. CustomMessageActivity -> Rep CustomMessageActivity x
Prelude.Generic)

-- |
-- Create a value of 'CustomMessageActivity' 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:
--
-- 'deliveryUri', 'customMessageActivity_deliveryUri' - The destination to send the campaign or treatment to. This value can be
-- one of the following:
--
-- -   The name or Amazon Resource Name (ARN) of an AWS Lambda function to
--     invoke to handle delivery of the campaign or treatment.
--
-- -   The URL for a web application or service that supports HTTPS and can
--     receive the message. The URL has to be a full URL, including the
--     HTTPS protocol.
--
-- 'endpointTypes', 'customMessageActivity_endpointTypes' - The types of endpoints to send the custom message to. Each valid value
-- maps to a type of channel that you can associate with an endpoint by
-- using the ChannelType property of an endpoint.
--
-- 'messageConfig', 'customMessageActivity_messageConfig' - Specifies the message data included in a custom channel message that\'s
-- sent to participants in a journey.
--
-- 'nextActivity', 'customMessageActivity_nextActivity' - The unique identifier for the next activity to perform, after Amazon
-- Pinpoint calls the AWS Lambda function or web hook.
--
-- 'templateName', 'customMessageActivity_templateName' - The name of the custom message template to use for the message. If
-- specified, this value must match the name of an existing message
-- template.
--
-- 'templateVersion', 'customMessageActivity_templateVersion' - The unique identifier for the version of the message 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.
newCustomMessageActivity ::
  CustomMessageActivity
newCustomMessageActivity :: CustomMessageActivity
newCustomMessageActivity =
  CustomMessageActivity'
    { $sel:deliveryUri:CustomMessageActivity' :: Maybe Text
deliveryUri =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endpointTypes:CustomMessageActivity' :: Maybe [EndpointTypesElement]
endpointTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:messageConfig:CustomMessageActivity' :: Maybe JourneyCustomMessage
messageConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:nextActivity:CustomMessageActivity' :: Maybe Text
nextActivity = forall a. Maybe a
Prelude.Nothing,
      $sel:templateName:CustomMessageActivity' :: Maybe Text
templateName = forall a. Maybe a
Prelude.Nothing,
      $sel:templateVersion:CustomMessageActivity' :: Maybe Text
templateVersion = forall a. Maybe a
Prelude.Nothing
    }

-- | The destination to send the campaign or treatment to. This value can be
-- one of the following:
--
-- -   The name or Amazon Resource Name (ARN) of an AWS Lambda function to
--     invoke to handle delivery of the campaign or treatment.
--
-- -   The URL for a web application or service that supports HTTPS and can
--     receive the message. The URL has to be a full URL, including the
--     HTTPS protocol.
customMessageActivity_deliveryUri :: Lens.Lens' CustomMessageActivity (Prelude.Maybe Prelude.Text)
customMessageActivity_deliveryUri :: Lens' CustomMessageActivity (Maybe Text)
customMessageActivity_deliveryUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomMessageActivity' {Maybe Text
deliveryUri :: Maybe Text
$sel:deliveryUri:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
deliveryUri} -> Maybe Text
deliveryUri) (\s :: CustomMessageActivity
s@CustomMessageActivity' {} Maybe Text
a -> CustomMessageActivity
s {$sel:deliveryUri:CustomMessageActivity' :: Maybe Text
deliveryUri = Maybe Text
a} :: CustomMessageActivity)

-- | The types of endpoints to send the custom message to. Each valid value
-- maps to a type of channel that you can associate with an endpoint by
-- using the ChannelType property of an endpoint.
customMessageActivity_endpointTypes :: Lens.Lens' CustomMessageActivity (Prelude.Maybe [EndpointTypesElement])
customMessageActivity_endpointTypes :: Lens' CustomMessageActivity (Maybe [EndpointTypesElement])
customMessageActivity_endpointTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomMessageActivity' {Maybe [EndpointTypesElement]
endpointTypes :: Maybe [EndpointTypesElement]
$sel:endpointTypes:CustomMessageActivity' :: CustomMessageActivity -> Maybe [EndpointTypesElement]
endpointTypes} -> Maybe [EndpointTypesElement]
endpointTypes) (\s :: CustomMessageActivity
s@CustomMessageActivity' {} Maybe [EndpointTypesElement]
a -> CustomMessageActivity
s {$sel:endpointTypes:CustomMessageActivity' :: Maybe [EndpointTypesElement]
endpointTypes = Maybe [EndpointTypesElement]
a} :: CustomMessageActivity) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the message data included in a custom channel message that\'s
-- sent to participants in a journey.
customMessageActivity_messageConfig :: Lens.Lens' CustomMessageActivity (Prelude.Maybe JourneyCustomMessage)
customMessageActivity_messageConfig :: Lens' CustomMessageActivity (Maybe JourneyCustomMessage)
customMessageActivity_messageConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomMessageActivity' {Maybe JourneyCustomMessage
messageConfig :: Maybe JourneyCustomMessage
$sel:messageConfig:CustomMessageActivity' :: CustomMessageActivity -> Maybe JourneyCustomMessage
messageConfig} -> Maybe JourneyCustomMessage
messageConfig) (\s :: CustomMessageActivity
s@CustomMessageActivity' {} Maybe JourneyCustomMessage
a -> CustomMessageActivity
s {$sel:messageConfig:CustomMessageActivity' :: Maybe JourneyCustomMessage
messageConfig = Maybe JourneyCustomMessage
a} :: CustomMessageActivity)

-- | The unique identifier for the next activity to perform, after Amazon
-- Pinpoint calls the AWS Lambda function or web hook.
customMessageActivity_nextActivity :: Lens.Lens' CustomMessageActivity (Prelude.Maybe Prelude.Text)
customMessageActivity_nextActivity :: Lens' CustomMessageActivity (Maybe Text)
customMessageActivity_nextActivity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomMessageActivity' {Maybe Text
nextActivity :: Maybe Text
$sel:nextActivity:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
nextActivity} -> Maybe Text
nextActivity) (\s :: CustomMessageActivity
s@CustomMessageActivity' {} Maybe Text
a -> CustomMessageActivity
s {$sel:nextActivity:CustomMessageActivity' :: Maybe Text
nextActivity = Maybe Text
a} :: CustomMessageActivity)

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

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

instance Data.FromJSON CustomMessageActivity where
  parseJSON :: Value -> Parser CustomMessageActivity
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomMessageActivity"
      ( \Object
x ->
          Maybe Text
-> Maybe [EndpointTypesElement]
-> Maybe JourneyCustomMessage
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CustomMessageActivity
CustomMessageActivity'
            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
"DeliveryUri")
            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
"EndpointTypes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"MessageConfig")
            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
"NextActivity")
            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
"TemplateName")
            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
"TemplateVersion")
      )

instance Prelude.Hashable CustomMessageActivity where
  hashWithSalt :: Int -> CustomMessageActivity -> Int
hashWithSalt Int
_salt CustomMessageActivity' {Maybe [EndpointTypesElement]
Maybe Text
Maybe JourneyCustomMessage
templateVersion :: Maybe Text
templateName :: Maybe Text
nextActivity :: Maybe Text
messageConfig :: Maybe JourneyCustomMessage
endpointTypes :: Maybe [EndpointTypesElement]
deliveryUri :: Maybe Text
$sel:templateVersion:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:templateName:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:nextActivity:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:messageConfig:CustomMessageActivity' :: CustomMessageActivity -> Maybe JourneyCustomMessage
$sel:endpointTypes:CustomMessageActivity' :: CustomMessageActivity -> Maybe [EndpointTypesElement]
$sel:deliveryUri:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deliveryUri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EndpointTypesElement]
endpointTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JourneyCustomMessage
messageConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextActivity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateVersion

instance Prelude.NFData CustomMessageActivity where
  rnf :: CustomMessageActivity -> ()
rnf CustomMessageActivity' {Maybe [EndpointTypesElement]
Maybe Text
Maybe JourneyCustomMessage
templateVersion :: Maybe Text
templateName :: Maybe Text
nextActivity :: Maybe Text
messageConfig :: Maybe JourneyCustomMessage
endpointTypes :: Maybe [EndpointTypesElement]
deliveryUri :: Maybe Text
$sel:templateVersion:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:templateName:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:nextActivity:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:messageConfig:CustomMessageActivity' :: CustomMessageActivity -> Maybe JourneyCustomMessage
$sel:endpointTypes:CustomMessageActivity' :: CustomMessageActivity -> Maybe [EndpointTypesElement]
$sel:deliveryUri:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deliveryUri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [EndpointTypesElement]
endpointTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JourneyCustomMessage
messageConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextActivity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateVersion

instance Data.ToJSON CustomMessageActivity where
  toJSON :: CustomMessageActivity -> Value
toJSON CustomMessageActivity' {Maybe [EndpointTypesElement]
Maybe Text
Maybe JourneyCustomMessage
templateVersion :: Maybe Text
templateName :: Maybe Text
nextActivity :: Maybe Text
messageConfig :: Maybe JourneyCustomMessage
endpointTypes :: Maybe [EndpointTypesElement]
deliveryUri :: Maybe Text
$sel:templateVersion:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:templateName:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:nextActivity:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
$sel:messageConfig:CustomMessageActivity' :: CustomMessageActivity -> Maybe JourneyCustomMessage
$sel:endpointTypes:CustomMessageActivity' :: CustomMessageActivity -> Maybe [EndpointTypesElement]
$sel:deliveryUri:CustomMessageActivity' :: CustomMessageActivity -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DeliveryUri" 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
deliveryUri,
            (Key
"EndpointTypes" 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 [EndpointTypesElement]
endpointTypes,
            (Key
"MessageConfig" 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 JourneyCustomMessage
messageConfig,
            (Key
"NextActivity" 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
nextActivity,
            (Key
"TemplateName" 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
templateName,
            (Key
"TemplateVersion" 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
templateVersion
          ]
      )