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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.InAppMessageContent
import Amazonka.Pinpoint.Types.Layout
import qualified Amazonka.Prelude as Prelude

-- | InApp Template Request.
--
-- /See:/ 'newInAppTemplateRequest' smart constructor.
data InAppTemplateRequest = InAppTemplateRequest'
  { -- | The layout of the message.
    InAppTemplateRequest -> Maybe Layout
layout :: Prelude.Maybe Layout,
    -- | The description of the template.
    InAppTemplateRequest -> Maybe Text
templateDescription :: Prelude.Maybe Prelude.Text,
    -- | The content of the message, can include up to 5 modals. Each modal must
    -- contain a message, a header, and background color. ImageUrl and buttons
    -- are optional.
    InAppTemplateRequest -> Maybe [InAppMessageContent]
content :: Prelude.Maybe [InAppMessageContent],
    -- | Custom config to be sent to client.
    InAppTemplateRequest -> Maybe (HashMap Text Text)
customConfig :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A string-to-string map of key-value pairs that defines the tags to
    -- associate with the message template. Each tag consists of a required tag
    -- key and an associated tag value.
    InAppTemplateRequest -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (InAppTemplateRequest -> InAppTemplateRequest -> Bool
(InAppTemplateRequest -> InAppTemplateRequest -> Bool)
-> (InAppTemplateRequest -> InAppTemplateRequest -> Bool)
-> Eq InAppTemplateRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InAppTemplateRequest -> InAppTemplateRequest -> Bool
$c/= :: InAppTemplateRequest -> InAppTemplateRequest -> Bool
== :: InAppTemplateRequest -> InAppTemplateRequest -> Bool
$c== :: InAppTemplateRequest -> InAppTemplateRequest -> Bool
Prelude.Eq, ReadPrec [InAppTemplateRequest]
ReadPrec InAppTemplateRequest
Int -> ReadS InAppTemplateRequest
ReadS [InAppTemplateRequest]
(Int -> ReadS InAppTemplateRequest)
-> ReadS [InAppTemplateRequest]
-> ReadPrec InAppTemplateRequest
-> ReadPrec [InAppTemplateRequest]
-> Read InAppTemplateRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InAppTemplateRequest]
$creadListPrec :: ReadPrec [InAppTemplateRequest]
readPrec :: ReadPrec InAppTemplateRequest
$creadPrec :: ReadPrec InAppTemplateRequest
readList :: ReadS [InAppTemplateRequest]
$creadList :: ReadS [InAppTemplateRequest]
readsPrec :: Int -> ReadS InAppTemplateRequest
$creadsPrec :: Int -> ReadS InAppTemplateRequest
Prelude.Read, Int -> InAppTemplateRequest -> ShowS
[InAppTemplateRequest] -> ShowS
InAppTemplateRequest -> String
(Int -> InAppTemplateRequest -> ShowS)
-> (InAppTemplateRequest -> String)
-> ([InAppTemplateRequest] -> ShowS)
-> Show InAppTemplateRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InAppTemplateRequest] -> ShowS
$cshowList :: [InAppTemplateRequest] -> ShowS
show :: InAppTemplateRequest -> String
$cshow :: InAppTemplateRequest -> String
showsPrec :: Int -> InAppTemplateRequest -> ShowS
$cshowsPrec :: Int -> InAppTemplateRequest -> ShowS
Prelude.Show, (forall x. InAppTemplateRequest -> Rep InAppTemplateRequest x)
-> (forall x. Rep InAppTemplateRequest x -> InAppTemplateRequest)
-> Generic InAppTemplateRequest
forall x. Rep InAppTemplateRequest x -> InAppTemplateRequest
forall x. InAppTemplateRequest -> Rep InAppTemplateRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InAppTemplateRequest x -> InAppTemplateRequest
$cfrom :: forall x. InAppTemplateRequest -> Rep InAppTemplateRequest x
Prelude.Generic)

-- |
-- Create a value of 'InAppTemplateRequest' 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:
--
-- 'layout', 'inAppTemplateRequest_layout' - The layout of the message.
--
-- 'templateDescription', 'inAppTemplateRequest_templateDescription' - The description of the template.
--
-- 'content', 'inAppTemplateRequest_content' - The content of the message, can include up to 5 modals. Each modal must
-- contain a message, a header, and background color. ImageUrl and buttons
-- are optional.
--
-- 'customConfig', 'inAppTemplateRequest_customConfig' - Custom config to be sent to client.
--
-- 'tags', 'inAppTemplateRequest_tags' - A string-to-string map of key-value pairs that defines the tags to
-- associate with the message template. Each tag consists of a required tag
-- key and an associated tag value.
newInAppTemplateRequest ::
  InAppTemplateRequest
newInAppTemplateRequest :: InAppTemplateRequest
newInAppTemplateRequest =
  InAppTemplateRequest' :: Maybe Layout
-> Maybe Text
-> Maybe [InAppMessageContent]
-> Maybe (HashMap Text Text)
-> Maybe (HashMap Text Text)
-> InAppTemplateRequest
InAppTemplateRequest'
    { $sel:layout:InAppTemplateRequest' :: Maybe Layout
layout = Maybe Layout
forall a. Maybe a
Prelude.Nothing,
      $sel:templateDescription:InAppTemplateRequest' :: Maybe Text
templateDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:content:InAppTemplateRequest' :: Maybe [InAppMessageContent]
content = Maybe [InAppMessageContent]
forall a. Maybe a
Prelude.Nothing,
      $sel:customConfig:InAppTemplateRequest' :: Maybe (HashMap Text Text)
customConfig = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:InAppTemplateRequest' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The layout of the message.
inAppTemplateRequest_layout :: Lens.Lens' InAppTemplateRequest (Prelude.Maybe Layout)
inAppTemplateRequest_layout :: (Maybe Layout -> f (Maybe Layout))
-> InAppTemplateRequest -> f InAppTemplateRequest
inAppTemplateRequest_layout = (InAppTemplateRequest -> Maybe Layout)
-> (InAppTemplateRequest -> Maybe Layout -> InAppTemplateRequest)
-> Lens
     InAppTemplateRequest
     InAppTemplateRequest
     (Maybe Layout)
     (Maybe Layout)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppTemplateRequest' {Maybe Layout
layout :: Maybe Layout
$sel:layout:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe Layout
layout} -> Maybe Layout
layout) (\s :: InAppTemplateRequest
s@InAppTemplateRequest' {} Maybe Layout
a -> InAppTemplateRequest
s {$sel:layout:InAppTemplateRequest' :: Maybe Layout
layout = Maybe Layout
a} :: InAppTemplateRequest)

-- | The description of the template.
inAppTemplateRequest_templateDescription :: Lens.Lens' InAppTemplateRequest (Prelude.Maybe Prelude.Text)
inAppTemplateRequest_templateDescription :: (Maybe Text -> f (Maybe Text))
-> InAppTemplateRequest -> f InAppTemplateRequest
inAppTemplateRequest_templateDescription = (InAppTemplateRequest -> Maybe Text)
-> (InAppTemplateRequest -> Maybe Text -> InAppTemplateRequest)
-> Lens
     InAppTemplateRequest InAppTemplateRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppTemplateRequest' {Maybe Text
templateDescription :: Maybe Text
$sel:templateDescription:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe Text
templateDescription} -> Maybe Text
templateDescription) (\s :: InAppTemplateRequest
s@InAppTemplateRequest' {} Maybe Text
a -> InAppTemplateRequest
s {$sel:templateDescription:InAppTemplateRequest' :: Maybe Text
templateDescription = Maybe Text
a} :: InAppTemplateRequest)

-- | The content of the message, can include up to 5 modals. Each modal must
-- contain a message, a header, and background color. ImageUrl and buttons
-- are optional.
inAppTemplateRequest_content :: Lens.Lens' InAppTemplateRequest (Prelude.Maybe [InAppMessageContent])
inAppTemplateRequest_content :: (Maybe [InAppMessageContent] -> f (Maybe [InAppMessageContent]))
-> InAppTemplateRequest -> f InAppTemplateRequest
inAppTemplateRequest_content = (InAppTemplateRequest -> Maybe [InAppMessageContent])
-> (InAppTemplateRequest
    -> Maybe [InAppMessageContent] -> InAppTemplateRequest)
-> Lens
     InAppTemplateRequest
     InAppTemplateRequest
     (Maybe [InAppMessageContent])
     (Maybe [InAppMessageContent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppTemplateRequest' {Maybe [InAppMessageContent]
content :: Maybe [InAppMessageContent]
$sel:content:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe [InAppMessageContent]
content} -> Maybe [InAppMessageContent]
content) (\s :: InAppTemplateRequest
s@InAppTemplateRequest' {} Maybe [InAppMessageContent]
a -> InAppTemplateRequest
s {$sel:content:InAppTemplateRequest' :: Maybe [InAppMessageContent]
content = Maybe [InAppMessageContent]
a} :: InAppTemplateRequest) ((Maybe [InAppMessageContent] -> f (Maybe [InAppMessageContent]))
 -> InAppTemplateRequest -> f InAppTemplateRequest)
-> ((Maybe [InAppMessageContent]
     -> f (Maybe [InAppMessageContent]))
    -> Maybe [InAppMessageContent] -> f (Maybe [InAppMessageContent]))
-> (Maybe [InAppMessageContent] -> f (Maybe [InAppMessageContent]))
-> InAppTemplateRequest
-> f InAppTemplateRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [InAppMessageContent]
  [InAppMessageContent]
  [InAppMessageContent]
  [InAppMessageContent]
-> Iso
     (Maybe [InAppMessageContent])
     (Maybe [InAppMessageContent])
     (Maybe [InAppMessageContent])
     (Maybe [InAppMessageContent])
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
  [InAppMessageContent]
  [InAppMessageContent]
  [InAppMessageContent]
  [InAppMessageContent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Custom config to be sent to client.
inAppTemplateRequest_customConfig :: Lens.Lens' InAppTemplateRequest (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
inAppTemplateRequest_customConfig :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> InAppTemplateRequest -> f InAppTemplateRequest
inAppTemplateRequest_customConfig = (InAppTemplateRequest -> Maybe (HashMap Text Text))
-> (InAppTemplateRequest
    -> Maybe (HashMap Text Text) -> InAppTemplateRequest)
-> Lens
     InAppTemplateRequest
     InAppTemplateRequest
     (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 (\InAppTemplateRequest' {Maybe (HashMap Text Text)
customConfig :: Maybe (HashMap Text Text)
$sel:customConfig:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe (HashMap Text Text)
customConfig} -> Maybe (HashMap Text Text)
customConfig) (\s :: InAppTemplateRequest
s@InAppTemplateRequest' {} Maybe (HashMap Text Text)
a -> InAppTemplateRequest
s {$sel:customConfig:InAppTemplateRequest' :: Maybe (HashMap Text Text)
customConfig = Maybe (HashMap Text Text)
a} :: InAppTemplateRequest) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> InAppTemplateRequest -> f InAppTemplateRequest)
-> ((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)))
-> InAppTemplateRequest
-> f InAppTemplateRequest
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

-- | A string-to-string map of key-value pairs that defines the tags to
-- associate with the message template. Each tag consists of a required tag
-- key and an associated tag value.
inAppTemplateRequest_tags :: Lens.Lens' InAppTemplateRequest (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
inAppTemplateRequest_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> InAppTemplateRequest -> f InAppTemplateRequest
inAppTemplateRequest_tags = (InAppTemplateRequest -> Maybe (HashMap Text Text))
-> (InAppTemplateRequest
    -> Maybe (HashMap Text Text) -> InAppTemplateRequest)
-> Lens
     InAppTemplateRequest
     InAppTemplateRequest
     (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 (\InAppTemplateRequest' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: InAppTemplateRequest
s@InAppTemplateRequest' {} Maybe (HashMap Text Text)
a -> InAppTemplateRequest
s {$sel:tags:InAppTemplateRequest' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: InAppTemplateRequest) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> InAppTemplateRequest -> f InAppTemplateRequest)
-> ((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)))
-> InAppTemplateRequest
-> f InAppTemplateRequest
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

instance Prelude.Hashable InAppTemplateRequest

instance Prelude.NFData InAppTemplateRequest

instance Core.ToJSON InAppTemplateRequest where
  toJSON :: InAppTemplateRequest -> Value
toJSON InAppTemplateRequest' {Maybe [InAppMessageContent]
Maybe Text
Maybe (HashMap Text Text)
Maybe Layout
tags :: Maybe (HashMap Text Text)
customConfig :: Maybe (HashMap Text Text)
content :: Maybe [InAppMessageContent]
templateDescription :: Maybe Text
layout :: Maybe Layout
$sel:tags:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe (HashMap Text Text)
$sel:customConfig:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe (HashMap Text Text)
$sel:content:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe [InAppMessageContent]
$sel:templateDescription:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe Text
$sel:layout:InAppTemplateRequest' :: InAppTemplateRequest -> Maybe Layout
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Layout" Text -> Layout -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Layout -> Pair) -> Maybe Layout -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Layout
layout,
            (Text
"TemplateDescription" 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
templateDescription,
            (Text
"Content" Text -> [InAppMessageContent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([InAppMessageContent] -> Pair)
-> Maybe [InAppMessageContent] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [InAppMessageContent]
content,
            (Text
"CustomConfig" 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)
customConfig,
            (Text
"tags" 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)
tags
          ]
      )