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

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

-- | Override button configuration.
--
-- /See:/ 'newOverrideButtonConfiguration' smart constructor.
data OverrideButtonConfiguration = OverrideButtonConfiguration'
  { -- | Button destination.
    OverrideButtonConfiguration -> Maybe Text
link :: Prelude.Maybe Prelude.Text,
    -- | Action triggered by the button.
    OverrideButtonConfiguration -> ButtonAction
buttonAction :: ButtonAction
  }
  deriving (OverrideButtonConfiguration -> OverrideButtonConfiguration -> Bool
(OverrideButtonConfiguration
 -> OverrideButtonConfiguration -> Bool)
-> (OverrideButtonConfiguration
    -> OverrideButtonConfiguration -> Bool)
-> Eq OverrideButtonConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OverrideButtonConfiguration -> OverrideButtonConfiguration -> Bool
$c/= :: OverrideButtonConfiguration -> OverrideButtonConfiguration -> Bool
== :: OverrideButtonConfiguration -> OverrideButtonConfiguration -> Bool
$c== :: OverrideButtonConfiguration -> OverrideButtonConfiguration -> Bool
Prelude.Eq, ReadPrec [OverrideButtonConfiguration]
ReadPrec OverrideButtonConfiguration
Int -> ReadS OverrideButtonConfiguration
ReadS [OverrideButtonConfiguration]
(Int -> ReadS OverrideButtonConfiguration)
-> ReadS [OverrideButtonConfiguration]
-> ReadPrec OverrideButtonConfiguration
-> ReadPrec [OverrideButtonConfiguration]
-> Read OverrideButtonConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OverrideButtonConfiguration]
$creadListPrec :: ReadPrec [OverrideButtonConfiguration]
readPrec :: ReadPrec OverrideButtonConfiguration
$creadPrec :: ReadPrec OverrideButtonConfiguration
readList :: ReadS [OverrideButtonConfiguration]
$creadList :: ReadS [OverrideButtonConfiguration]
readsPrec :: Int -> ReadS OverrideButtonConfiguration
$creadsPrec :: Int -> ReadS OverrideButtonConfiguration
Prelude.Read, Int -> OverrideButtonConfiguration -> ShowS
[OverrideButtonConfiguration] -> ShowS
OverrideButtonConfiguration -> String
(Int -> OverrideButtonConfiguration -> ShowS)
-> (OverrideButtonConfiguration -> String)
-> ([OverrideButtonConfiguration] -> ShowS)
-> Show OverrideButtonConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OverrideButtonConfiguration] -> ShowS
$cshowList :: [OverrideButtonConfiguration] -> ShowS
show :: OverrideButtonConfiguration -> String
$cshow :: OverrideButtonConfiguration -> String
showsPrec :: Int -> OverrideButtonConfiguration -> ShowS
$cshowsPrec :: Int -> OverrideButtonConfiguration -> ShowS
Prelude.Show, (forall x.
 OverrideButtonConfiguration -> Rep OverrideButtonConfiguration x)
-> (forall x.
    Rep OverrideButtonConfiguration x -> OverrideButtonConfiguration)
-> Generic OverrideButtonConfiguration
forall x.
Rep OverrideButtonConfiguration x -> OverrideButtonConfiguration
forall x.
OverrideButtonConfiguration -> Rep OverrideButtonConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OverrideButtonConfiguration x -> OverrideButtonConfiguration
$cfrom :: forall x.
OverrideButtonConfiguration -> Rep OverrideButtonConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'OverrideButtonConfiguration' 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:
--
-- 'link', 'overrideButtonConfiguration_link' - Button destination.
--
-- 'buttonAction', 'overrideButtonConfiguration_buttonAction' - Action triggered by the button.
newOverrideButtonConfiguration ::
  -- | 'buttonAction'
  ButtonAction ->
  OverrideButtonConfiguration
newOverrideButtonConfiguration :: ButtonAction -> OverrideButtonConfiguration
newOverrideButtonConfiguration ButtonAction
pButtonAction_ =
  OverrideButtonConfiguration' :: Maybe Text -> ButtonAction -> OverrideButtonConfiguration
OverrideButtonConfiguration'
    { $sel:link:OverrideButtonConfiguration' :: Maybe Text
link =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:buttonAction:OverrideButtonConfiguration' :: ButtonAction
buttonAction = ButtonAction
pButtonAction_
    }

-- | Button destination.
overrideButtonConfiguration_link :: Lens.Lens' OverrideButtonConfiguration (Prelude.Maybe Prelude.Text)
overrideButtonConfiguration_link :: (Maybe Text -> f (Maybe Text))
-> OverrideButtonConfiguration -> f OverrideButtonConfiguration
overrideButtonConfiguration_link = (OverrideButtonConfiguration -> Maybe Text)
-> (OverrideButtonConfiguration
    -> Maybe Text -> OverrideButtonConfiguration)
-> Lens
     OverrideButtonConfiguration
     OverrideButtonConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OverrideButtonConfiguration' {Maybe Text
link :: Maybe Text
$sel:link:OverrideButtonConfiguration' :: OverrideButtonConfiguration -> Maybe Text
link} -> Maybe Text
link) (\s :: OverrideButtonConfiguration
s@OverrideButtonConfiguration' {} Maybe Text
a -> OverrideButtonConfiguration
s {$sel:link:OverrideButtonConfiguration' :: Maybe Text
link = Maybe Text
a} :: OverrideButtonConfiguration)

-- | Action triggered by the button.
overrideButtonConfiguration_buttonAction :: Lens.Lens' OverrideButtonConfiguration ButtonAction
overrideButtonConfiguration_buttonAction :: (ButtonAction -> f ButtonAction)
-> OverrideButtonConfiguration -> f OverrideButtonConfiguration
overrideButtonConfiguration_buttonAction = (OverrideButtonConfiguration -> ButtonAction)
-> (OverrideButtonConfiguration
    -> ButtonAction -> OverrideButtonConfiguration)
-> Lens
     OverrideButtonConfiguration
     OverrideButtonConfiguration
     ButtonAction
     ButtonAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OverrideButtonConfiguration' {ButtonAction
buttonAction :: ButtonAction
$sel:buttonAction:OverrideButtonConfiguration' :: OverrideButtonConfiguration -> ButtonAction
buttonAction} -> ButtonAction
buttonAction) (\s :: OverrideButtonConfiguration
s@OverrideButtonConfiguration' {} ButtonAction
a -> OverrideButtonConfiguration
s {$sel:buttonAction:OverrideButtonConfiguration' :: ButtonAction
buttonAction = ButtonAction
a} :: OverrideButtonConfiguration)

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

instance Prelude.Hashable OverrideButtonConfiguration

instance Prelude.NFData OverrideButtonConfiguration

instance Core.ToJSON OverrideButtonConfiguration where
  toJSON :: OverrideButtonConfiguration -> Value
toJSON OverrideButtonConfiguration' {Maybe Text
ButtonAction
buttonAction :: ButtonAction
link :: Maybe Text
$sel:buttonAction:OverrideButtonConfiguration' :: OverrideButtonConfiguration -> ButtonAction
$sel:link:OverrideButtonConfiguration' :: OverrideButtonConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Link" 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
link,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ButtonAction" Text -> ButtonAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ButtonAction
buttonAction)
          ]
      )