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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.DefaultButtonConfiguration
import Amazonka.Pinpoint.Types.OverrideButtonConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Button Config for an in-app message.
--
-- /See:/ 'newInAppMessageButton' smart constructor.
data InAppMessageButton = InAppMessageButton'
  { -- | Default button content.
    InAppMessageButton -> Maybe OverrideButtonConfiguration
ios :: Prelude.Maybe OverrideButtonConfiguration,
    -- | Default button content.
    InAppMessageButton -> Maybe DefaultButtonConfiguration
defaultConfig :: Prelude.Maybe DefaultButtonConfiguration,
    -- | Default button content.
    InAppMessageButton -> Maybe OverrideButtonConfiguration
web :: Prelude.Maybe OverrideButtonConfiguration,
    -- | Default button content.
    InAppMessageButton -> Maybe OverrideButtonConfiguration
android :: Prelude.Maybe OverrideButtonConfiguration
  }
  deriving (InAppMessageButton -> InAppMessageButton -> Bool
(InAppMessageButton -> InAppMessageButton -> Bool)
-> (InAppMessageButton -> InAppMessageButton -> Bool)
-> Eq InAppMessageButton
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InAppMessageButton -> InAppMessageButton -> Bool
$c/= :: InAppMessageButton -> InAppMessageButton -> Bool
== :: InAppMessageButton -> InAppMessageButton -> Bool
$c== :: InAppMessageButton -> InAppMessageButton -> Bool
Prelude.Eq, ReadPrec [InAppMessageButton]
ReadPrec InAppMessageButton
Int -> ReadS InAppMessageButton
ReadS [InAppMessageButton]
(Int -> ReadS InAppMessageButton)
-> ReadS [InAppMessageButton]
-> ReadPrec InAppMessageButton
-> ReadPrec [InAppMessageButton]
-> Read InAppMessageButton
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InAppMessageButton]
$creadListPrec :: ReadPrec [InAppMessageButton]
readPrec :: ReadPrec InAppMessageButton
$creadPrec :: ReadPrec InAppMessageButton
readList :: ReadS [InAppMessageButton]
$creadList :: ReadS [InAppMessageButton]
readsPrec :: Int -> ReadS InAppMessageButton
$creadsPrec :: Int -> ReadS InAppMessageButton
Prelude.Read, Int -> InAppMessageButton -> ShowS
[InAppMessageButton] -> ShowS
InAppMessageButton -> String
(Int -> InAppMessageButton -> ShowS)
-> (InAppMessageButton -> String)
-> ([InAppMessageButton] -> ShowS)
-> Show InAppMessageButton
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InAppMessageButton] -> ShowS
$cshowList :: [InAppMessageButton] -> ShowS
show :: InAppMessageButton -> String
$cshow :: InAppMessageButton -> String
showsPrec :: Int -> InAppMessageButton -> ShowS
$cshowsPrec :: Int -> InAppMessageButton -> ShowS
Prelude.Show, (forall x. InAppMessageButton -> Rep InAppMessageButton x)
-> (forall x. Rep InAppMessageButton x -> InAppMessageButton)
-> Generic InAppMessageButton
forall x. Rep InAppMessageButton x -> InAppMessageButton
forall x. InAppMessageButton -> Rep InAppMessageButton x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InAppMessageButton x -> InAppMessageButton
$cfrom :: forall x. InAppMessageButton -> Rep InAppMessageButton x
Prelude.Generic)

-- |
-- Create a value of 'InAppMessageButton' 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:
--
-- 'ios', 'inAppMessageButton_ios' - Default button content.
--
-- 'defaultConfig', 'inAppMessageButton_defaultConfig' - Default button content.
--
-- 'web', 'inAppMessageButton_web' - Default button content.
--
-- 'android', 'inAppMessageButton_android' - Default button content.
newInAppMessageButton ::
  InAppMessageButton
newInAppMessageButton :: InAppMessageButton
newInAppMessageButton =
  InAppMessageButton' :: Maybe OverrideButtonConfiguration
-> Maybe DefaultButtonConfiguration
-> Maybe OverrideButtonConfiguration
-> Maybe OverrideButtonConfiguration
-> InAppMessageButton
InAppMessageButton'
    { $sel:ios:InAppMessageButton' :: Maybe OverrideButtonConfiguration
ios = Maybe OverrideButtonConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultConfig:InAppMessageButton' :: Maybe DefaultButtonConfiguration
defaultConfig = Maybe DefaultButtonConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:web:InAppMessageButton' :: Maybe OverrideButtonConfiguration
web = Maybe OverrideButtonConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:android:InAppMessageButton' :: Maybe OverrideButtonConfiguration
android = Maybe OverrideButtonConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Default button content.
inAppMessageButton_ios :: Lens.Lens' InAppMessageButton (Prelude.Maybe OverrideButtonConfiguration)
inAppMessageButton_ios :: (Maybe OverrideButtonConfiguration
 -> f (Maybe OverrideButtonConfiguration))
-> InAppMessageButton -> f InAppMessageButton
inAppMessageButton_ios = (InAppMessageButton -> Maybe OverrideButtonConfiguration)
-> (InAppMessageButton
    -> Maybe OverrideButtonConfiguration -> InAppMessageButton)
-> Lens
     InAppMessageButton
     InAppMessageButton
     (Maybe OverrideButtonConfiguration)
     (Maybe OverrideButtonConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageButton' {Maybe OverrideButtonConfiguration
ios :: Maybe OverrideButtonConfiguration
$sel:ios:InAppMessageButton' :: InAppMessageButton -> Maybe OverrideButtonConfiguration
ios} -> Maybe OverrideButtonConfiguration
ios) (\s :: InAppMessageButton
s@InAppMessageButton' {} Maybe OverrideButtonConfiguration
a -> InAppMessageButton
s {$sel:ios:InAppMessageButton' :: Maybe OverrideButtonConfiguration
ios = Maybe OverrideButtonConfiguration
a} :: InAppMessageButton)

-- | Default button content.
inAppMessageButton_defaultConfig :: Lens.Lens' InAppMessageButton (Prelude.Maybe DefaultButtonConfiguration)
inAppMessageButton_defaultConfig :: (Maybe DefaultButtonConfiguration
 -> f (Maybe DefaultButtonConfiguration))
-> InAppMessageButton -> f InAppMessageButton
inAppMessageButton_defaultConfig = (InAppMessageButton -> Maybe DefaultButtonConfiguration)
-> (InAppMessageButton
    -> Maybe DefaultButtonConfiguration -> InAppMessageButton)
-> Lens
     InAppMessageButton
     InAppMessageButton
     (Maybe DefaultButtonConfiguration)
     (Maybe DefaultButtonConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageButton' {Maybe DefaultButtonConfiguration
defaultConfig :: Maybe DefaultButtonConfiguration
$sel:defaultConfig:InAppMessageButton' :: InAppMessageButton -> Maybe DefaultButtonConfiguration
defaultConfig} -> Maybe DefaultButtonConfiguration
defaultConfig) (\s :: InAppMessageButton
s@InAppMessageButton' {} Maybe DefaultButtonConfiguration
a -> InAppMessageButton
s {$sel:defaultConfig:InAppMessageButton' :: Maybe DefaultButtonConfiguration
defaultConfig = Maybe DefaultButtonConfiguration
a} :: InAppMessageButton)

-- | Default button content.
inAppMessageButton_web :: Lens.Lens' InAppMessageButton (Prelude.Maybe OverrideButtonConfiguration)
inAppMessageButton_web :: (Maybe OverrideButtonConfiguration
 -> f (Maybe OverrideButtonConfiguration))
-> InAppMessageButton -> f InAppMessageButton
inAppMessageButton_web = (InAppMessageButton -> Maybe OverrideButtonConfiguration)
-> (InAppMessageButton
    -> Maybe OverrideButtonConfiguration -> InAppMessageButton)
-> Lens
     InAppMessageButton
     InAppMessageButton
     (Maybe OverrideButtonConfiguration)
     (Maybe OverrideButtonConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageButton' {Maybe OverrideButtonConfiguration
web :: Maybe OverrideButtonConfiguration
$sel:web:InAppMessageButton' :: InAppMessageButton -> Maybe OverrideButtonConfiguration
web} -> Maybe OverrideButtonConfiguration
web) (\s :: InAppMessageButton
s@InAppMessageButton' {} Maybe OverrideButtonConfiguration
a -> InAppMessageButton
s {$sel:web:InAppMessageButton' :: Maybe OverrideButtonConfiguration
web = Maybe OverrideButtonConfiguration
a} :: InAppMessageButton)

-- | Default button content.
inAppMessageButton_android :: Lens.Lens' InAppMessageButton (Prelude.Maybe OverrideButtonConfiguration)
inAppMessageButton_android :: (Maybe OverrideButtonConfiguration
 -> f (Maybe OverrideButtonConfiguration))
-> InAppMessageButton -> f InAppMessageButton
inAppMessageButton_android = (InAppMessageButton -> Maybe OverrideButtonConfiguration)
-> (InAppMessageButton
    -> Maybe OverrideButtonConfiguration -> InAppMessageButton)
-> Lens
     InAppMessageButton
     InAppMessageButton
     (Maybe OverrideButtonConfiguration)
     (Maybe OverrideButtonConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppMessageButton' {Maybe OverrideButtonConfiguration
android :: Maybe OverrideButtonConfiguration
$sel:android:InAppMessageButton' :: InAppMessageButton -> Maybe OverrideButtonConfiguration
android} -> Maybe OverrideButtonConfiguration
android) (\s :: InAppMessageButton
s@InAppMessageButton' {} Maybe OverrideButtonConfiguration
a -> InAppMessageButton
s {$sel:android:InAppMessageButton' :: Maybe OverrideButtonConfiguration
android = Maybe OverrideButtonConfiguration
a} :: InAppMessageButton)

instance Core.FromJSON InAppMessageButton where
  parseJSON :: Value -> Parser InAppMessageButton
parseJSON =
    String
-> (Object -> Parser InAppMessageButton)
-> Value
-> Parser InAppMessageButton
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InAppMessageButton"
      ( \Object
x ->
          Maybe OverrideButtonConfiguration
-> Maybe DefaultButtonConfiguration
-> Maybe OverrideButtonConfiguration
-> Maybe OverrideButtonConfiguration
-> InAppMessageButton
InAppMessageButton'
            (Maybe OverrideButtonConfiguration
 -> Maybe DefaultButtonConfiguration
 -> Maybe OverrideButtonConfiguration
 -> Maybe OverrideButtonConfiguration
 -> InAppMessageButton)
-> Parser (Maybe OverrideButtonConfiguration)
-> Parser
     (Maybe DefaultButtonConfiguration
      -> Maybe OverrideButtonConfiguration
      -> Maybe OverrideButtonConfiguration
      -> InAppMessageButton)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OverrideButtonConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IOS")
            Parser
  (Maybe DefaultButtonConfiguration
   -> Maybe OverrideButtonConfiguration
   -> Maybe OverrideButtonConfiguration
   -> InAppMessageButton)
-> Parser (Maybe DefaultButtonConfiguration)
-> Parser
     (Maybe OverrideButtonConfiguration
      -> Maybe OverrideButtonConfiguration -> InAppMessageButton)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DefaultButtonConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DefaultConfig")
            Parser
  (Maybe OverrideButtonConfiguration
   -> Maybe OverrideButtonConfiguration -> InAppMessageButton)
-> Parser (Maybe OverrideButtonConfiguration)
-> Parser (Maybe OverrideButtonConfiguration -> InAppMessageButton)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OverrideButtonConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Web")
            Parser (Maybe OverrideButtonConfiguration -> InAppMessageButton)
-> Parser (Maybe OverrideButtonConfiguration)
-> Parser InAppMessageButton
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OverrideButtonConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Android")
      )

instance Prelude.Hashable InAppMessageButton

instance Prelude.NFData InAppMessageButton

instance Core.ToJSON InAppMessageButton where
  toJSON :: InAppMessageButton -> Value
toJSON InAppMessageButton' {Maybe DefaultButtonConfiguration
Maybe OverrideButtonConfiguration
android :: Maybe OverrideButtonConfiguration
web :: Maybe OverrideButtonConfiguration
defaultConfig :: Maybe DefaultButtonConfiguration
ios :: Maybe OverrideButtonConfiguration
$sel:android:InAppMessageButton' :: InAppMessageButton -> Maybe OverrideButtonConfiguration
$sel:web:InAppMessageButton' :: InAppMessageButton -> Maybe OverrideButtonConfiguration
$sel:defaultConfig:InAppMessageButton' :: InAppMessageButton -> Maybe DefaultButtonConfiguration
$sel:ios:InAppMessageButton' :: InAppMessageButton -> Maybe OverrideButtonConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IOS" Text -> OverrideButtonConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OverrideButtonConfiguration -> Pair)
-> Maybe OverrideButtonConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OverrideButtonConfiguration
ios,
            (Text
"DefaultConfig" Text -> DefaultButtonConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DefaultButtonConfiguration -> Pair)
-> Maybe DefaultButtonConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DefaultButtonConfiguration
defaultConfig,
            (Text
"Web" Text -> OverrideButtonConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OverrideButtonConfiguration -> Pair)
-> Maybe OverrideButtonConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OverrideButtonConfiguration
web,
            (Text
"Android" Text -> OverrideButtonConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OverrideButtonConfiguration -> Pair)
-> Maybe OverrideButtonConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OverrideButtonConfiguration
android
          ]
      )