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

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

-- | Specifies the default message for all channels.
--
-- /See:/ 'newDefaultMessage' smart constructor.
data DefaultMessage = DefaultMessage'
  { -- | The default message variables to use in the message. You can override
    -- these default variables with individual address variables.
    DefaultMessage -> Maybe (HashMap Text [Text])
substitutions :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The default body of the message.
    DefaultMessage -> Maybe Text
body :: Prelude.Maybe Prelude.Text
  }
  deriving (DefaultMessage -> DefaultMessage -> Bool
(DefaultMessage -> DefaultMessage -> Bool)
-> (DefaultMessage -> DefaultMessage -> Bool) -> Eq DefaultMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultMessage -> DefaultMessage -> Bool
$c/= :: DefaultMessage -> DefaultMessage -> Bool
== :: DefaultMessage -> DefaultMessage -> Bool
$c== :: DefaultMessage -> DefaultMessage -> Bool
Prelude.Eq, ReadPrec [DefaultMessage]
ReadPrec DefaultMessage
Int -> ReadS DefaultMessage
ReadS [DefaultMessage]
(Int -> ReadS DefaultMessage)
-> ReadS [DefaultMessage]
-> ReadPrec DefaultMessage
-> ReadPrec [DefaultMessage]
-> Read DefaultMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefaultMessage]
$creadListPrec :: ReadPrec [DefaultMessage]
readPrec :: ReadPrec DefaultMessage
$creadPrec :: ReadPrec DefaultMessage
readList :: ReadS [DefaultMessage]
$creadList :: ReadS [DefaultMessage]
readsPrec :: Int -> ReadS DefaultMessage
$creadsPrec :: Int -> ReadS DefaultMessage
Prelude.Read, Int -> DefaultMessage -> ShowS
[DefaultMessage] -> ShowS
DefaultMessage -> String
(Int -> DefaultMessage -> ShowS)
-> (DefaultMessage -> String)
-> ([DefaultMessage] -> ShowS)
-> Show DefaultMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefaultMessage] -> ShowS
$cshowList :: [DefaultMessage] -> ShowS
show :: DefaultMessage -> String
$cshow :: DefaultMessage -> String
showsPrec :: Int -> DefaultMessage -> ShowS
$cshowsPrec :: Int -> DefaultMessage -> ShowS
Prelude.Show, (forall x. DefaultMessage -> Rep DefaultMessage x)
-> (forall x. Rep DefaultMessage x -> DefaultMessage)
-> Generic DefaultMessage
forall x. Rep DefaultMessage x -> DefaultMessage
forall x. DefaultMessage -> Rep DefaultMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DefaultMessage x -> DefaultMessage
$cfrom :: forall x. DefaultMessage -> Rep DefaultMessage x
Prelude.Generic)

-- |
-- Create a value of 'DefaultMessage' 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', 'defaultMessage_substitutions' - The default message variables to use in the message. You can override
-- these default variables with individual address variables.
--
-- 'body', 'defaultMessage_body' - The default body of the message.
newDefaultMessage ::
  DefaultMessage
newDefaultMessage :: DefaultMessage
newDefaultMessage =
  DefaultMessage' :: Maybe (HashMap Text [Text]) -> Maybe Text -> DefaultMessage
DefaultMessage'
    { $sel:substitutions:DefaultMessage' :: Maybe (HashMap Text [Text])
substitutions = Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:body:DefaultMessage' :: Maybe Text
body = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The default message variables to use in the message. You can override
-- these default variables with individual address variables.
defaultMessage_substitutions :: Lens.Lens' DefaultMessage (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
defaultMessage_substitutions :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> DefaultMessage -> f DefaultMessage
defaultMessage_substitutions = (DefaultMessage -> Maybe (HashMap Text [Text]))
-> (DefaultMessage
    -> Maybe (HashMap Text [Text]) -> DefaultMessage)
-> Lens
     DefaultMessage
     DefaultMessage
     (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 (\DefaultMessage' {Maybe (HashMap Text [Text])
substitutions :: Maybe (HashMap Text [Text])
$sel:substitutions:DefaultMessage' :: DefaultMessage -> Maybe (HashMap Text [Text])
substitutions} -> Maybe (HashMap Text [Text])
substitutions) (\s :: DefaultMessage
s@DefaultMessage' {} Maybe (HashMap Text [Text])
a -> DefaultMessage
s {$sel:substitutions:DefaultMessage' :: Maybe (HashMap Text [Text])
substitutions = Maybe (HashMap Text [Text])
a} :: DefaultMessage) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> DefaultMessage -> f DefaultMessage)
-> ((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])))
-> DefaultMessage
-> f DefaultMessage
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 default body of the message.
defaultMessage_body :: Lens.Lens' DefaultMessage (Prelude.Maybe Prelude.Text)
defaultMessage_body :: (Maybe Text -> f (Maybe Text))
-> DefaultMessage -> f DefaultMessage
defaultMessage_body = (DefaultMessage -> Maybe Text)
-> (DefaultMessage -> Maybe Text -> DefaultMessage)
-> Lens DefaultMessage DefaultMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultMessage' {Maybe Text
body :: Maybe Text
$sel:body:DefaultMessage' :: DefaultMessage -> Maybe Text
body} -> Maybe Text
body) (\s :: DefaultMessage
s@DefaultMessage' {} Maybe Text
a -> DefaultMessage
s {$sel:body:DefaultMessage' :: Maybe Text
body = Maybe Text
a} :: DefaultMessage)

instance Prelude.Hashable DefaultMessage

instance Prelude.NFData DefaultMessage

instance Core.ToJSON DefaultMessage where
  toJSON :: DefaultMessage -> Value
toJSON DefaultMessage' {Maybe Text
Maybe (HashMap Text [Text])
body :: Maybe Text
substitutions :: Maybe (HashMap Text [Text])
$sel:body:DefaultMessage' :: DefaultMessage -> Maybe Text
$sel:substitutions:DefaultMessage' :: DefaultMessage -> 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
"Body" 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
body
          ]
      )