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

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

-- | Specifies address-based configuration settings for a message that\'s
-- sent directly to an endpoint.
--
-- /See:/ 'newAddressConfiguration' smart constructor.
data AddressConfiguration = AddressConfiguration'
  { -- | A map of the message variables to merge with the variables specified by
    -- properties of the DefaultMessage object. The variables specified in this
    -- map take precedence over all other variables.
    AddressConfiguration -> Maybe (HashMap Text [Text])
substitutions :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The message title to use instead of the default message title. This
    -- value overrides the default message title.
    AddressConfiguration -> Maybe Text
titleOverride :: Prelude.Maybe Prelude.Text,
    -- | An object that maps custom attributes to attributes for the address and
    -- is attached to the message. 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.
    AddressConfiguration -> 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.
    AddressConfiguration -> Maybe Text
rawContent :: Prelude.Maybe Prelude.Text,
    -- | The message body to use instead of the default message body. This value
    -- overrides the default message body.
    AddressConfiguration -> Maybe Text
bodyOverride :: Prelude.Maybe Prelude.Text,
    -- | The channel to use when sending the message.
    AddressConfiguration -> Maybe ChannelType
channelType :: Prelude.Maybe ChannelType
  }
  deriving (AddressConfiguration -> AddressConfiguration -> Bool
(AddressConfiguration -> AddressConfiguration -> Bool)
-> (AddressConfiguration -> AddressConfiguration -> Bool)
-> Eq AddressConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddressConfiguration -> AddressConfiguration -> Bool
$c/= :: AddressConfiguration -> AddressConfiguration -> Bool
== :: AddressConfiguration -> AddressConfiguration -> Bool
$c== :: AddressConfiguration -> AddressConfiguration -> Bool
Prelude.Eq, ReadPrec [AddressConfiguration]
ReadPrec AddressConfiguration
Int -> ReadS AddressConfiguration
ReadS [AddressConfiguration]
(Int -> ReadS AddressConfiguration)
-> ReadS [AddressConfiguration]
-> ReadPrec AddressConfiguration
-> ReadPrec [AddressConfiguration]
-> Read AddressConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddressConfiguration]
$creadListPrec :: ReadPrec [AddressConfiguration]
readPrec :: ReadPrec AddressConfiguration
$creadPrec :: ReadPrec AddressConfiguration
readList :: ReadS [AddressConfiguration]
$creadList :: ReadS [AddressConfiguration]
readsPrec :: Int -> ReadS AddressConfiguration
$creadsPrec :: Int -> ReadS AddressConfiguration
Prelude.Read, Int -> AddressConfiguration -> ShowS
[AddressConfiguration] -> ShowS
AddressConfiguration -> String
(Int -> AddressConfiguration -> ShowS)
-> (AddressConfiguration -> String)
-> ([AddressConfiguration] -> ShowS)
-> Show AddressConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddressConfiguration] -> ShowS
$cshowList :: [AddressConfiguration] -> ShowS
show :: AddressConfiguration -> String
$cshow :: AddressConfiguration -> String
showsPrec :: Int -> AddressConfiguration -> ShowS
$cshowsPrec :: Int -> AddressConfiguration -> ShowS
Prelude.Show, (forall x. AddressConfiguration -> Rep AddressConfiguration x)
-> (forall x. Rep AddressConfiguration x -> AddressConfiguration)
-> Generic AddressConfiguration
forall x. Rep AddressConfiguration x -> AddressConfiguration
forall x. AddressConfiguration -> Rep AddressConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddressConfiguration x -> AddressConfiguration
$cfrom :: forall x. AddressConfiguration -> Rep AddressConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AddressConfiguration' 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', 'addressConfiguration_substitutions' - A map of the message variables to merge with the variables specified by
-- properties of the DefaultMessage object. The variables specified in this
-- map take precedence over all other variables.
--
-- 'titleOverride', 'addressConfiguration_titleOverride' - The message title to use instead of the default message title. This
-- value overrides the default message title.
--
-- 'context', 'addressConfiguration_context' - An object that maps custom attributes to attributes for the address and
-- is attached to the message. 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', 'addressConfiguration_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', 'addressConfiguration_bodyOverride' - The message body to use instead of the default message body. This value
-- overrides the default message body.
--
-- 'channelType', 'addressConfiguration_channelType' - The channel to use when sending the message.
newAddressConfiguration ::
  AddressConfiguration
newAddressConfiguration :: AddressConfiguration
newAddressConfiguration =
  AddressConfiguration' :: Maybe (HashMap Text [Text])
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe ChannelType
-> AddressConfiguration
AddressConfiguration'
    { $sel:substitutions:AddressConfiguration' :: Maybe (HashMap Text [Text])
substitutions =
        Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:titleOverride:AddressConfiguration' :: Maybe Text
titleOverride = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:context:AddressConfiguration' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:rawContent:AddressConfiguration' :: Maybe Text
rawContent = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bodyOverride:AddressConfiguration' :: Maybe Text
bodyOverride = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:channelType:AddressConfiguration' :: Maybe ChannelType
channelType = Maybe ChannelType
forall a. Maybe a
Prelude.Nothing
    }

-- | A map of the message variables to merge with the variables specified by
-- properties of the DefaultMessage object. The variables specified in this
-- map take precedence over all other variables.
addressConfiguration_substitutions :: Lens.Lens' AddressConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
addressConfiguration_substitutions :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> AddressConfiguration -> f AddressConfiguration
addressConfiguration_substitutions = (AddressConfiguration -> Maybe (HashMap Text [Text]))
-> (AddressConfiguration
    -> Maybe (HashMap Text [Text]) -> AddressConfiguration)
-> Lens
     AddressConfiguration
     AddressConfiguration
     (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 (\AddressConfiguration' {Maybe (HashMap Text [Text])
substitutions :: Maybe (HashMap Text [Text])
$sel:substitutions:AddressConfiguration' :: AddressConfiguration -> Maybe (HashMap Text [Text])
substitutions} -> Maybe (HashMap Text [Text])
substitutions) (\s :: AddressConfiguration
s@AddressConfiguration' {} Maybe (HashMap Text [Text])
a -> AddressConfiguration
s {$sel:substitutions:AddressConfiguration' :: Maybe (HashMap Text [Text])
substitutions = Maybe (HashMap Text [Text])
a} :: AddressConfiguration) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> AddressConfiguration -> f AddressConfiguration)
-> ((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])))
-> AddressConfiguration
-> f AddressConfiguration
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 message title to use instead of the default message title. This
-- value overrides the default message title.
addressConfiguration_titleOverride :: Lens.Lens' AddressConfiguration (Prelude.Maybe Prelude.Text)
addressConfiguration_titleOverride :: (Maybe Text -> f (Maybe Text))
-> AddressConfiguration -> f AddressConfiguration
addressConfiguration_titleOverride = (AddressConfiguration -> Maybe Text)
-> (AddressConfiguration -> Maybe Text -> AddressConfiguration)
-> Lens
     AddressConfiguration AddressConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddressConfiguration' {Maybe Text
titleOverride :: Maybe Text
$sel:titleOverride:AddressConfiguration' :: AddressConfiguration -> Maybe Text
titleOverride} -> Maybe Text
titleOverride) (\s :: AddressConfiguration
s@AddressConfiguration' {} Maybe Text
a -> AddressConfiguration
s {$sel:titleOverride:AddressConfiguration' :: Maybe Text
titleOverride = Maybe Text
a} :: AddressConfiguration)

-- | An object that maps custom attributes to attributes for the address and
-- is attached to the message. 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.
addressConfiguration_context :: Lens.Lens' AddressConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
addressConfiguration_context :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AddressConfiguration -> f AddressConfiguration
addressConfiguration_context = (AddressConfiguration -> Maybe (HashMap Text Text))
-> (AddressConfiguration
    -> Maybe (HashMap Text Text) -> AddressConfiguration)
-> Lens
     AddressConfiguration
     AddressConfiguration
     (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 (\AddressConfiguration' {Maybe (HashMap Text Text)
context :: Maybe (HashMap Text Text)
$sel:context:AddressConfiguration' :: AddressConfiguration -> Maybe (HashMap Text Text)
context} -> Maybe (HashMap Text Text)
context) (\s :: AddressConfiguration
s@AddressConfiguration' {} Maybe (HashMap Text Text)
a -> AddressConfiguration
s {$sel:context:AddressConfiguration' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
a} :: AddressConfiguration) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> AddressConfiguration -> f AddressConfiguration)
-> ((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)))
-> AddressConfiguration
-> f AddressConfiguration
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.
addressConfiguration_rawContent :: Lens.Lens' AddressConfiguration (Prelude.Maybe Prelude.Text)
addressConfiguration_rawContent :: (Maybe Text -> f (Maybe Text))
-> AddressConfiguration -> f AddressConfiguration
addressConfiguration_rawContent = (AddressConfiguration -> Maybe Text)
-> (AddressConfiguration -> Maybe Text -> AddressConfiguration)
-> Lens
     AddressConfiguration AddressConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddressConfiguration' {Maybe Text
rawContent :: Maybe Text
$sel:rawContent:AddressConfiguration' :: AddressConfiguration -> Maybe Text
rawContent} -> Maybe Text
rawContent) (\s :: AddressConfiguration
s@AddressConfiguration' {} Maybe Text
a -> AddressConfiguration
s {$sel:rawContent:AddressConfiguration' :: Maybe Text
rawContent = Maybe Text
a} :: AddressConfiguration)

-- | The message body to use instead of the default message body. This value
-- overrides the default message body.
addressConfiguration_bodyOverride :: Lens.Lens' AddressConfiguration (Prelude.Maybe Prelude.Text)
addressConfiguration_bodyOverride :: (Maybe Text -> f (Maybe Text))
-> AddressConfiguration -> f AddressConfiguration
addressConfiguration_bodyOverride = (AddressConfiguration -> Maybe Text)
-> (AddressConfiguration -> Maybe Text -> AddressConfiguration)
-> Lens
     AddressConfiguration AddressConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddressConfiguration' {Maybe Text
bodyOverride :: Maybe Text
$sel:bodyOverride:AddressConfiguration' :: AddressConfiguration -> Maybe Text
bodyOverride} -> Maybe Text
bodyOverride) (\s :: AddressConfiguration
s@AddressConfiguration' {} Maybe Text
a -> AddressConfiguration
s {$sel:bodyOverride:AddressConfiguration' :: Maybe Text
bodyOverride = Maybe Text
a} :: AddressConfiguration)

-- | The channel to use when sending the message.
addressConfiguration_channelType :: Lens.Lens' AddressConfiguration (Prelude.Maybe ChannelType)
addressConfiguration_channelType :: (Maybe ChannelType -> f (Maybe ChannelType))
-> AddressConfiguration -> f AddressConfiguration
addressConfiguration_channelType = (AddressConfiguration -> Maybe ChannelType)
-> (AddressConfiguration
    -> Maybe ChannelType -> AddressConfiguration)
-> Lens
     AddressConfiguration
     AddressConfiguration
     (Maybe ChannelType)
     (Maybe ChannelType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddressConfiguration' {Maybe ChannelType
channelType :: Maybe ChannelType
$sel:channelType:AddressConfiguration' :: AddressConfiguration -> Maybe ChannelType
channelType} -> Maybe ChannelType
channelType) (\s :: AddressConfiguration
s@AddressConfiguration' {} Maybe ChannelType
a -> AddressConfiguration
s {$sel:channelType:AddressConfiguration' :: Maybe ChannelType
channelType = Maybe ChannelType
a} :: AddressConfiguration)

instance Prelude.Hashable AddressConfiguration

instance Prelude.NFData AddressConfiguration

instance Core.ToJSON AddressConfiguration where
  toJSON :: AddressConfiguration -> Value
toJSON AddressConfiguration' {Maybe Text
Maybe (HashMap Text [Text])
Maybe (HashMap Text Text)
Maybe ChannelType
channelType :: Maybe ChannelType
bodyOverride :: Maybe Text
rawContent :: Maybe Text
context :: Maybe (HashMap Text Text)
titleOverride :: Maybe Text
substitutions :: Maybe (HashMap Text [Text])
$sel:channelType:AddressConfiguration' :: AddressConfiguration -> Maybe ChannelType
$sel:bodyOverride:AddressConfiguration' :: AddressConfiguration -> Maybe Text
$sel:rawContent:AddressConfiguration' :: AddressConfiguration -> Maybe Text
$sel:context:AddressConfiguration' :: AddressConfiguration -> Maybe (HashMap Text Text)
$sel:titleOverride:AddressConfiguration' :: AddressConfiguration -> Maybe Text
$sel:substitutions:AddressConfiguration' :: AddressConfiguration -> 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,
            (Text
"ChannelType" Text -> ChannelType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ChannelType -> Pair) -> Maybe ChannelType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelType
channelType
          ]
      )