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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the content, including message variables and attributes, to
-- use in a message that\'s sent directly to an endpoint.
--
-- /See:/ 'newEndpointSendConfiguration' smart constructor.
data EndpointSendConfiguration = EndpointSendConfiguration'
  { -- | A map of the message variables to merge with the variables specified for
    -- the default message (DefaultMessage.Substitutions). The variables
    -- specified in this map take precedence over all other variables.
    EndpointSendConfiguration -> Maybe (HashMap Text [Text])
substitutions :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The title or subject line of the message. If specified, this value
    -- overrides the default message title or subject line.
    EndpointSendConfiguration -> Maybe Text
titleOverride :: Prelude.Maybe Prelude.Text,
    -- | A map of custom attributes to attach to the message for the address.
    -- Attribute names are case sensitive.
    --
    -- For a push notification, this payload is added to the data.pinpoint
    -- object. For an email or text message, this payload is added to
    -- email\/SMS delivery receipt event attributes.
    EndpointSendConfiguration -> Maybe (HashMap Text Text)
context :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The raw, JSON-formatted string to use as the payload for the message. If
    -- specified, this value overrides all other values for the message.
    EndpointSendConfiguration -> Maybe Text
rawContent :: Prelude.Maybe Prelude.Text,
    -- | The body of the message. If specified, this value overrides the default
    -- message body.
    EndpointSendConfiguration -> Maybe Text
bodyOverride :: Prelude.Maybe Prelude.Text
  }
  deriving (EndpointSendConfiguration -> EndpointSendConfiguration -> Bool
(EndpointSendConfiguration -> EndpointSendConfiguration -> Bool)
-> (EndpointSendConfiguration -> EndpointSendConfiguration -> Bool)
-> Eq EndpointSendConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointSendConfiguration -> EndpointSendConfiguration -> Bool
$c/= :: EndpointSendConfiguration -> EndpointSendConfiguration -> Bool
== :: EndpointSendConfiguration -> EndpointSendConfiguration -> Bool
$c== :: EndpointSendConfiguration -> EndpointSendConfiguration -> Bool
Prelude.Eq, ReadPrec [EndpointSendConfiguration]
ReadPrec EndpointSendConfiguration
Int -> ReadS EndpointSendConfiguration
ReadS [EndpointSendConfiguration]
(Int -> ReadS EndpointSendConfiguration)
-> ReadS [EndpointSendConfiguration]
-> ReadPrec EndpointSendConfiguration
-> ReadPrec [EndpointSendConfiguration]
-> Read EndpointSendConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointSendConfiguration]
$creadListPrec :: ReadPrec [EndpointSendConfiguration]
readPrec :: ReadPrec EndpointSendConfiguration
$creadPrec :: ReadPrec EndpointSendConfiguration
readList :: ReadS [EndpointSendConfiguration]
$creadList :: ReadS [EndpointSendConfiguration]
readsPrec :: Int -> ReadS EndpointSendConfiguration
$creadsPrec :: Int -> ReadS EndpointSendConfiguration
Prelude.Read, Int -> EndpointSendConfiguration -> ShowS
[EndpointSendConfiguration] -> ShowS
EndpointSendConfiguration -> String
(Int -> EndpointSendConfiguration -> ShowS)
-> (EndpointSendConfiguration -> String)
-> ([EndpointSendConfiguration] -> ShowS)
-> Show EndpointSendConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointSendConfiguration] -> ShowS
$cshowList :: [EndpointSendConfiguration] -> ShowS
show :: EndpointSendConfiguration -> String
$cshow :: EndpointSendConfiguration -> String
showsPrec :: Int -> EndpointSendConfiguration -> ShowS
$cshowsPrec :: Int -> EndpointSendConfiguration -> ShowS
Prelude.Show, (forall x.
 EndpointSendConfiguration -> Rep EndpointSendConfiguration x)
-> (forall x.
    Rep EndpointSendConfiguration x -> EndpointSendConfiguration)
-> Generic EndpointSendConfiguration
forall x.
Rep EndpointSendConfiguration x -> EndpointSendConfiguration
forall x.
EndpointSendConfiguration -> Rep EndpointSendConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EndpointSendConfiguration x -> EndpointSendConfiguration
$cfrom :: forall x.
EndpointSendConfiguration -> Rep EndpointSendConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EndpointSendConfiguration' 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:
--
-- 'substitutions', 'endpointSendConfiguration_substitutions' - A map of the message variables to merge with the variables specified for
-- the default message (DefaultMessage.Substitutions). The variables
-- specified in this map take precedence over all other variables.
--
-- 'titleOverride', 'endpointSendConfiguration_titleOverride' - The title or subject line of the message. If specified, this value
-- overrides the default message title or subject line.
--
-- 'context', 'endpointSendConfiguration_context' - A map of custom attributes to attach to the message for the address.
-- Attribute names are case sensitive.
--
-- For a push notification, this payload is added to the data.pinpoint
-- object. For an email or text message, this payload is added to
-- email\/SMS delivery receipt event attributes.
--
-- 'rawContent', 'endpointSendConfiguration_rawContent' - The raw, JSON-formatted string to use as the payload for the message. If
-- specified, this value overrides all other values for the message.
--
-- 'bodyOverride', 'endpointSendConfiguration_bodyOverride' - The body of the message. If specified, this value overrides the default
-- message body.
newEndpointSendConfiguration ::
  EndpointSendConfiguration
newEndpointSendConfiguration :: EndpointSendConfiguration
newEndpointSendConfiguration =
  EndpointSendConfiguration' :: Maybe (HashMap Text [Text])
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> EndpointSendConfiguration
EndpointSendConfiguration'
    { $sel:substitutions:EndpointSendConfiguration' :: Maybe (HashMap Text [Text])
substitutions =
        Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:titleOverride:EndpointSendConfiguration' :: Maybe Text
titleOverride = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:context:EndpointSendConfiguration' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:rawContent:EndpointSendConfiguration' :: Maybe Text
rawContent = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bodyOverride:EndpointSendConfiguration' :: Maybe Text
bodyOverride = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A map of the message variables to merge with the variables specified for
-- the default message (DefaultMessage.Substitutions). The variables
-- specified in this map take precedence over all other variables.
endpointSendConfiguration_substitutions :: Lens.Lens' EndpointSendConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
endpointSendConfiguration_substitutions :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> EndpointSendConfiguration -> f EndpointSendConfiguration
endpointSendConfiguration_substitutions = (EndpointSendConfiguration -> Maybe (HashMap Text [Text]))
-> (EndpointSendConfiguration
    -> Maybe (HashMap Text [Text]) -> EndpointSendConfiguration)
-> Lens
     EndpointSendConfiguration
     EndpointSendConfiguration
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointSendConfiguration' {Maybe (HashMap Text [Text])
substitutions :: Maybe (HashMap Text [Text])
$sel:substitutions:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe (HashMap Text [Text])
substitutions} -> Maybe (HashMap Text [Text])
substitutions) (\s :: EndpointSendConfiguration
s@EndpointSendConfiguration' {} Maybe (HashMap Text [Text])
a -> EndpointSendConfiguration
s {$sel:substitutions:EndpointSendConfiguration' :: Maybe (HashMap Text [Text])
substitutions = Maybe (HashMap Text [Text])
a} :: EndpointSendConfiguration) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> EndpointSendConfiguration -> f EndpointSendConfiguration)
-> ((Maybe (HashMap Text [Text])
     -> f (Maybe (HashMap Text [Text])))
    -> Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> EndpointSendConfiguration
-> f EndpointSendConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
-> Iso
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
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 AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The title or subject line of the message. If specified, this value
-- overrides the default message title or subject line.
endpointSendConfiguration_titleOverride :: Lens.Lens' EndpointSendConfiguration (Prelude.Maybe Prelude.Text)
endpointSendConfiguration_titleOverride :: (Maybe Text -> f (Maybe Text))
-> EndpointSendConfiguration -> f EndpointSendConfiguration
endpointSendConfiguration_titleOverride = (EndpointSendConfiguration -> Maybe Text)
-> (EndpointSendConfiguration
    -> Maybe Text -> EndpointSendConfiguration)
-> Lens
     EndpointSendConfiguration
     EndpointSendConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointSendConfiguration' {Maybe Text
titleOverride :: Maybe Text
$sel:titleOverride:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe Text
titleOverride} -> Maybe Text
titleOverride) (\s :: EndpointSendConfiguration
s@EndpointSendConfiguration' {} Maybe Text
a -> EndpointSendConfiguration
s {$sel:titleOverride:EndpointSendConfiguration' :: Maybe Text
titleOverride = Maybe Text
a} :: EndpointSendConfiguration)

-- | A map of custom attributes to attach to the message for the address.
-- Attribute names are case sensitive.
--
-- For a push notification, this payload is added to the data.pinpoint
-- object. For an email or text message, this payload is added to
-- email\/SMS delivery receipt event attributes.
endpointSendConfiguration_context :: Lens.Lens' EndpointSendConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
endpointSendConfiguration_context :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EndpointSendConfiguration -> f EndpointSendConfiguration
endpointSendConfiguration_context = (EndpointSendConfiguration -> Maybe (HashMap Text Text))
-> (EndpointSendConfiguration
    -> Maybe (HashMap Text Text) -> EndpointSendConfiguration)
-> Lens
     EndpointSendConfiguration
     EndpointSendConfiguration
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointSendConfiguration' {Maybe (HashMap Text Text)
context :: Maybe (HashMap Text Text)
$sel:context:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe (HashMap Text Text)
context} -> Maybe (HashMap Text Text)
context) (\s :: EndpointSendConfiguration
s@EndpointSendConfiguration' {} Maybe (HashMap Text Text)
a -> EndpointSendConfiguration
s {$sel:context:EndpointSendConfiguration' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
a} :: EndpointSendConfiguration) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> EndpointSendConfiguration -> f EndpointSendConfiguration)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EndpointSendConfiguration
-> f EndpointSendConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The raw, JSON-formatted string to use as the payload for the message. If
-- specified, this value overrides all other values for the message.
endpointSendConfiguration_rawContent :: Lens.Lens' EndpointSendConfiguration (Prelude.Maybe Prelude.Text)
endpointSendConfiguration_rawContent :: (Maybe Text -> f (Maybe Text))
-> EndpointSendConfiguration -> f EndpointSendConfiguration
endpointSendConfiguration_rawContent = (EndpointSendConfiguration -> Maybe Text)
-> (EndpointSendConfiguration
    -> Maybe Text -> EndpointSendConfiguration)
-> Lens
     EndpointSendConfiguration
     EndpointSendConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointSendConfiguration' {Maybe Text
rawContent :: Maybe Text
$sel:rawContent:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe Text
rawContent} -> Maybe Text
rawContent) (\s :: EndpointSendConfiguration
s@EndpointSendConfiguration' {} Maybe Text
a -> EndpointSendConfiguration
s {$sel:rawContent:EndpointSendConfiguration' :: Maybe Text
rawContent = Maybe Text
a} :: EndpointSendConfiguration)

-- | The body of the message. If specified, this value overrides the default
-- message body.
endpointSendConfiguration_bodyOverride :: Lens.Lens' EndpointSendConfiguration (Prelude.Maybe Prelude.Text)
endpointSendConfiguration_bodyOverride :: (Maybe Text -> f (Maybe Text))
-> EndpointSendConfiguration -> f EndpointSendConfiguration
endpointSendConfiguration_bodyOverride = (EndpointSendConfiguration -> Maybe Text)
-> (EndpointSendConfiguration
    -> Maybe Text -> EndpointSendConfiguration)
-> Lens
     EndpointSendConfiguration
     EndpointSendConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointSendConfiguration' {Maybe Text
bodyOverride :: Maybe Text
$sel:bodyOverride:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe Text
bodyOverride} -> Maybe Text
bodyOverride) (\s :: EndpointSendConfiguration
s@EndpointSendConfiguration' {} Maybe Text
a -> EndpointSendConfiguration
s {$sel:bodyOverride:EndpointSendConfiguration' :: Maybe Text
bodyOverride = Maybe Text
a} :: EndpointSendConfiguration)

instance Prelude.Hashable EndpointSendConfiguration

instance Prelude.NFData EndpointSendConfiguration

instance Core.ToJSON EndpointSendConfiguration where
  toJSON :: EndpointSendConfiguration -> Value
toJSON EndpointSendConfiguration' {Maybe Text
Maybe (HashMap Text [Text])
Maybe (HashMap Text Text)
bodyOverride :: Maybe Text
rawContent :: Maybe Text
context :: Maybe (HashMap Text Text)
titleOverride :: Maybe Text
substitutions :: Maybe (HashMap Text [Text])
$sel:bodyOverride:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe Text
$sel:rawContent:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe Text
$sel:context:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe (HashMap Text Text)
$sel:titleOverride:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe Text
$sel:substitutions:EndpointSendConfiguration' :: EndpointSendConfiguration -> Maybe (HashMap Text [Text])
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Substitutions" Text -> HashMap Text [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text [Text] -> Pair)
-> Maybe (HashMap Text [Text]) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text [Text])
substitutions,
            (Text
"TitleOverride" 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
titleOverride,
            (Text
"Context" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
context,
            (Text
"RawContent" 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
rawContent,
            (Text
"BodyOverride" 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
bodyOverride
          ]
      )