{-# 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.InAppMessageContent
-- 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.InAppMessageContent 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.InAppMessageBodyConfig
import Amazonka.Pinpoint.Types.InAppMessageButton
import Amazonka.Pinpoint.Types.InAppMessageHeaderConfig
import qualified Amazonka.Prelude as Prelude

-- | The configuration for the message content.
--
-- /See:/ 'newInAppMessageContent' smart constructor.
data InAppMessageContent = InAppMessageContent'
  { -- | The background color for the message.
    InAppMessageContent -> Maybe Text
backgroundColor :: Prelude.Maybe Prelude.Text,
    -- | The configuration for the message body.
    InAppMessageContent -> Maybe InAppMessageBodyConfig
bodyConfig :: Prelude.Maybe InAppMessageBodyConfig,
    -- | The configuration for the message header.
    InAppMessageContent -> Maybe InAppMessageHeaderConfig
headerConfig :: Prelude.Maybe InAppMessageHeaderConfig,
    -- | The image url for the background of message.
    InAppMessageContent -> Maybe Text
imageUrl :: Prelude.Maybe Prelude.Text,
    -- | The first button inside the message.
    InAppMessageContent -> Maybe InAppMessageButton
primaryBtn :: Prelude.Maybe InAppMessageButton,
    -- | The second button inside message.
    InAppMessageContent -> Maybe InAppMessageButton
secondaryBtn :: Prelude.Maybe InAppMessageButton
  }
  deriving (InAppMessageContent -> InAppMessageContent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InAppMessageContent -> InAppMessageContent -> Bool
$c/= :: InAppMessageContent -> InAppMessageContent -> Bool
== :: InAppMessageContent -> InAppMessageContent -> Bool
$c== :: InAppMessageContent -> InAppMessageContent -> Bool
Prelude.Eq, ReadPrec [InAppMessageContent]
ReadPrec InAppMessageContent
Int -> ReadS InAppMessageContent
ReadS [InAppMessageContent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InAppMessageContent]
$creadListPrec :: ReadPrec [InAppMessageContent]
readPrec :: ReadPrec InAppMessageContent
$creadPrec :: ReadPrec InAppMessageContent
readList :: ReadS [InAppMessageContent]
$creadList :: ReadS [InAppMessageContent]
readsPrec :: Int -> ReadS InAppMessageContent
$creadsPrec :: Int -> ReadS InAppMessageContent
Prelude.Read, Int -> InAppMessageContent -> ShowS
[InAppMessageContent] -> ShowS
InAppMessageContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InAppMessageContent] -> ShowS
$cshowList :: [InAppMessageContent] -> ShowS
show :: InAppMessageContent -> String
$cshow :: InAppMessageContent -> String
showsPrec :: Int -> InAppMessageContent -> ShowS
$cshowsPrec :: Int -> InAppMessageContent -> ShowS
Prelude.Show, forall x. Rep InAppMessageContent x -> InAppMessageContent
forall x. InAppMessageContent -> Rep InAppMessageContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InAppMessageContent x -> InAppMessageContent
$cfrom :: forall x. InAppMessageContent -> Rep InAppMessageContent x
Prelude.Generic)

-- |
-- Create a value of 'InAppMessageContent' 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:
--
-- 'backgroundColor', 'inAppMessageContent_backgroundColor' - The background color for the message.
--
-- 'bodyConfig', 'inAppMessageContent_bodyConfig' - The configuration for the message body.
--
-- 'headerConfig', 'inAppMessageContent_headerConfig' - The configuration for the message header.
--
-- 'imageUrl', 'inAppMessageContent_imageUrl' - The image url for the background of message.
--
-- 'primaryBtn', 'inAppMessageContent_primaryBtn' - The first button inside the message.
--
-- 'secondaryBtn', 'inAppMessageContent_secondaryBtn' - The second button inside message.
newInAppMessageContent ::
  InAppMessageContent
newInAppMessageContent :: InAppMessageContent
newInAppMessageContent =
  InAppMessageContent'
    { $sel:backgroundColor:InAppMessageContent' :: Maybe Text
backgroundColor =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bodyConfig:InAppMessageContent' :: Maybe InAppMessageBodyConfig
bodyConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:headerConfig:InAppMessageContent' :: Maybe InAppMessageHeaderConfig
headerConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:imageUrl:InAppMessageContent' :: Maybe Text
imageUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:primaryBtn:InAppMessageContent' :: Maybe InAppMessageButton
primaryBtn = forall a. Maybe a
Prelude.Nothing,
      $sel:secondaryBtn:InAppMessageContent' :: Maybe InAppMessageButton
secondaryBtn = forall a. Maybe a
Prelude.Nothing
    }

-- | The background color for the message.
inAppMessageContent_backgroundColor :: Lens.Lens' InAppMessageContent (Prelude.Maybe Prelude.Text)
inAppMessageContent_backgroundColor :: Lens' InAppMessageContent (Maybe Text)
inAppMessageContent_backgroundColor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageContent' {Maybe Text
backgroundColor :: Maybe Text
$sel:backgroundColor:InAppMessageContent' :: InAppMessageContent -> Maybe Text
backgroundColor} -> Maybe Text
backgroundColor) (\s :: InAppMessageContent
s@InAppMessageContent' {} Maybe Text
a -> InAppMessageContent
s {$sel:backgroundColor:InAppMessageContent' :: Maybe Text
backgroundColor = Maybe Text
a} :: InAppMessageContent)

-- | The configuration for the message body.
inAppMessageContent_bodyConfig :: Lens.Lens' InAppMessageContent (Prelude.Maybe InAppMessageBodyConfig)
inAppMessageContent_bodyConfig :: Lens' InAppMessageContent (Maybe InAppMessageBodyConfig)
inAppMessageContent_bodyConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageContent' {Maybe InAppMessageBodyConfig
bodyConfig :: Maybe InAppMessageBodyConfig
$sel:bodyConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageBodyConfig
bodyConfig} -> Maybe InAppMessageBodyConfig
bodyConfig) (\s :: InAppMessageContent
s@InAppMessageContent' {} Maybe InAppMessageBodyConfig
a -> InAppMessageContent
s {$sel:bodyConfig:InAppMessageContent' :: Maybe InAppMessageBodyConfig
bodyConfig = Maybe InAppMessageBodyConfig
a} :: InAppMessageContent)

-- | The configuration for the message header.
inAppMessageContent_headerConfig :: Lens.Lens' InAppMessageContent (Prelude.Maybe InAppMessageHeaderConfig)
inAppMessageContent_headerConfig :: Lens' InAppMessageContent (Maybe InAppMessageHeaderConfig)
inAppMessageContent_headerConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageContent' {Maybe InAppMessageHeaderConfig
headerConfig :: Maybe InAppMessageHeaderConfig
$sel:headerConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageHeaderConfig
headerConfig} -> Maybe InAppMessageHeaderConfig
headerConfig) (\s :: InAppMessageContent
s@InAppMessageContent' {} Maybe InAppMessageHeaderConfig
a -> InAppMessageContent
s {$sel:headerConfig:InAppMessageContent' :: Maybe InAppMessageHeaderConfig
headerConfig = Maybe InAppMessageHeaderConfig
a} :: InAppMessageContent)

-- | The image url for the background of message.
inAppMessageContent_imageUrl :: Lens.Lens' InAppMessageContent (Prelude.Maybe Prelude.Text)
inAppMessageContent_imageUrl :: Lens' InAppMessageContent (Maybe Text)
inAppMessageContent_imageUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageContent' {Maybe Text
imageUrl :: Maybe Text
$sel:imageUrl:InAppMessageContent' :: InAppMessageContent -> Maybe Text
imageUrl} -> Maybe Text
imageUrl) (\s :: InAppMessageContent
s@InAppMessageContent' {} Maybe Text
a -> InAppMessageContent
s {$sel:imageUrl:InAppMessageContent' :: Maybe Text
imageUrl = Maybe Text
a} :: InAppMessageContent)

-- | The first button inside the message.
inAppMessageContent_primaryBtn :: Lens.Lens' InAppMessageContent (Prelude.Maybe InAppMessageButton)
inAppMessageContent_primaryBtn :: Lens' InAppMessageContent (Maybe InAppMessageButton)
inAppMessageContent_primaryBtn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageContent' {Maybe InAppMessageButton
primaryBtn :: Maybe InAppMessageButton
$sel:primaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
primaryBtn} -> Maybe InAppMessageButton
primaryBtn) (\s :: InAppMessageContent
s@InAppMessageContent' {} Maybe InAppMessageButton
a -> InAppMessageContent
s {$sel:primaryBtn:InAppMessageContent' :: Maybe InAppMessageButton
primaryBtn = Maybe InAppMessageButton
a} :: InAppMessageContent)

-- | The second button inside message.
inAppMessageContent_secondaryBtn :: Lens.Lens' InAppMessageContent (Prelude.Maybe InAppMessageButton)
inAppMessageContent_secondaryBtn :: Lens' InAppMessageContent (Maybe InAppMessageButton)
inAppMessageContent_secondaryBtn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageContent' {Maybe InAppMessageButton
secondaryBtn :: Maybe InAppMessageButton
$sel:secondaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
secondaryBtn} -> Maybe InAppMessageButton
secondaryBtn) (\s :: InAppMessageContent
s@InAppMessageContent' {} Maybe InAppMessageButton
a -> InAppMessageContent
s {$sel:secondaryBtn:InAppMessageContent' :: Maybe InAppMessageButton
secondaryBtn = Maybe InAppMessageButton
a} :: InAppMessageContent)

instance Data.FromJSON InAppMessageContent where
  parseJSON :: Value -> Parser InAppMessageContent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InAppMessageContent"
      ( \Object
x ->
          Maybe Text
-> Maybe InAppMessageBodyConfig
-> Maybe InAppMessageHeaderConfig
-> Maybe Text
-> Maybe InAppMessageButton
-> Maybe InAppMessageButton
-> InAppMessageContent
InAppMessageContent'
            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
"BackgroundColor")
            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
"BodyConfig")
            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
"HeaderConfig")
            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
"ImageUrl")
            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
"PrimaryBtn")
            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
"SecondaryBtn")
      )

instance Prelude.Hashable InAppMessageContent where
  hashWithSalt :: Int -> InAppMessageContent -> Int
hashWithSalt Int
_salt InAppMessageContent' {Maybe Text
Maybe InAppMessageBodyConfig
Maybe InAppMessageHeaderConfig
Maybe InAppMessageButton
secondaryBtn :: Maybe InAppMessageButton
primaryBtn :: Maybe InAppMessageButton
imageUrl :: Maybe Text
headerConfig :: Maybe InAppMessageHeaderConfig
bodyConfig :: Maybe InAppMessageBodyConfig
backgroundColor :: Maybe Text
$sel:secondaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
$sel:primaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
$sel:imageUrl:InAppMessageContent' :: InAppMessageContent -> Maybe Text
$sel:headerConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageHeaderConfig
$sel:bodyConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageBodyConfig
$sel:backgroundColor:InAppMessageContent' :: InAppMessageContent -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
backgroundColor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InAppMessageBodyConfig
bodyConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InAppMessageHeaderConfig
headerConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
imageUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InAppMessageButton
primaryBtn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InAppMessageButton
secondaryBtn

instance Prelude.NFData InAppMessageContent where
  rnf :: InAppMessageContent -> ()
rnf InAppMessageContent' {Maybe Text
Maybe InAppMessageBodyConfig
Maybe InAppMessageHeaderConfig
Maybe InAppMessageButton
secondaryBtn :: Maybe InAppMessageButton
primaryBtn :: Maybe InAppMessageButton
imageUrl :: Maybe Text
headerConfig :: Maybe InAppMessageHeaderConfig
bodyConfig :: Maybe InAppMessageBodyConfig
backgroundColor :: Maybe Text
$sel:secondaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
$sel:primaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
$sel:imageUrl:InAppMessageContent' :: InAppMessageContent -> Maybe Text
$sel:headerConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageHeaderConfig
$sel:bodyConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageBodyConfig
$sel:backgroundColor:InAppMessageContent' :: InAppMessageContent -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
backgroundColor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InAppMessageBodyConfig
bodyConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InAppMessageHeaderConfig
headerConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
imageUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InAppMessageButton
primaryBtn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InAppMessageButton
secondaryBtn

instance Data.ToJSON InAppMessageContent where
  toJSON :: InAppMessageContent -> Value
toJSON InAppMessageContent' {Maybe Text
Maybe InAppMessageBodyConfig
Maybe InAppMessageHeaderConfig
Maybe InAppMessageButton
secondaryBtn :: Maybe InAppMessageButton
primaryBtn :: Maybe InAppMessageButton
imageUrl :: Maybe Text
headerConfig :: Maybe InAppMessageHeaderConfig
bodyConfig :: Maybe InAppMessageBodyConfig
backgroundColor :: Maybe Text
$sel:secondaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
$sel:primaryBtn:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageButton
$sel:imageUrl:InAppMessageContent' :: InAppMessageContent -> Maybe Text
$sel:headerConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageHeaderConfig
$sel:bodyConfig:InAppMessageContent' :: InAppMessageContent -> Maybe InAppMessageBodyConfig
$sel:backgroundColor:InAppMessageContent' :: InAppMessageContent -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BackgroundColor" 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
backgroundColor,
            (Key
"BodyConfig" 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 InAppMessageBodyConfig
bodyConfig,
            (Key
"HeaderConfig" 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 InAppMessageHeaderConfig
headerConfig,
            (Key
"ImageUrl" 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
imageUrl,
            (Key
"PrimaryBtn" 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 InAppMessageButton
primaryBtn,
            (Key
"SecondaryBtn" 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 InAppMessageButton
secondaryBtn
          ]
      )