{-# 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.LexRuntime.Types.Button
-- 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.LexRuntime.Types.Button where

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

-- | Represents an option to be shown on the client platform (Facebook,
-- Slack, etc.)
--
-- /See:/ 'newButton' smart constructor.
data Button = Button'
  { -- | Text that is visible to the user on the button.
    Button -> Text
text :: Prelude.Text,
    -- | The value sent to Amazon Lex when a user chooses the button. For
    -- example, consider button text \"NYC.\" When the user chooses the button,
    -- the value sent can be \"New York City.\"
    Button -> Text
value :: Prelude.Text
  }
  deriving (Button -> Button -> Bool
(Button -> Button -> Bool)
-> (Button -> Button -> Bool) -> Eq Button
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Button -> Button -> Bool
$c/= :: Button -> Button -> Bool
== :: Button -> Button -> Bool
$c== :: Button -> Button -> Bool
Prelude.Eq, ReadPrec [Button]
ReadPrec Button
Int -> ReadS Button
ReadS [Button]
(Int -> ReadS Button)
-> ReadS [Button]
-> ReadPrec Button
-> ReadPrec [Button]
-> Read Button
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Button]
$creadListPrec :: ReadPrec [Button]
readPrec :: ReadPrec Button
$creadPrec :: ReadPrec Button
readList :: ReadS [Button]
$creadList :: ReadS [Button]
readsPrec :: Int -> ReadS Button
$creadsPrec :: Int -> ReadS Button
Prelude.Read, Int -> Button -> ShowS
[Button] -> ShowS
Button -> String
(Int -> Button -> ShowS)
-> (Button -> String) -> ([Button] -> ShowS) -> Show Button
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Button] -> ShowS
$cshowList :: [Button] -> ShowS
show :: Button -> String
$cshow :: Button -> String
showsPrec :: Int -> Button -> ShowS
$cshowsPrec :: Int -> Button -> ShowS
Prelude.Show, (forall x. Button -> Rep Button x)
-> (forall x. Rep Button x -> Button) -> Generic Button
forall x. Rep Button x -> Button
forall x. Button -> Rep Button x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Button x -> Button
$cfrom :: forall x. Button -> Rep Button x
Prelude.Generic)

-- |
-- Create a value of 'Button' 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:
--
-- 'text', 'button_text' - Text that is visible to the user on the button.
--
-- 'value', 'button_value' - The value sent to Amazon Lex when a user chooses the button. For
-- example, consider button text \"NYC.\" When the user chooses the button,
-- the value sent can be \"New York City.\"
newButton ::
  -- | 'text'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  Button
newButton :: Text -> Text -> Button
newButton Text
pText_ Text
pValue_ =
  Button' :: Text -> Text -> Button
Button' {$sel:text:Button' :: Text
text = Text
pText_, $sel:value:Button' :: Text
value = Text
pValue_}

-- | Text that is visible to the user on the button.
button_text :: Lens.Lens' Button Prelude.Text
button_text :: (Text -> f Text) -> Button -> f Button
button_text = (Button -> Text)
-> (Button -> Text -> Button) -> Lens Button Button Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Button' {Text
text :: Text
$sel:text:Button' :: Button -> Text
text} -> Text
text) (\s :: Button
s@Button' {} Text
a -> Button
s {$sel:text:Button' :: Text
text = Text
a} :: Button)

-- | The value sent to Amazon Lex when a user chooses the button. For
-- example, consider button text \"NYC.\" When the user chooses the button,
-- the value sent can be \"New York City.\"
button_value :: Lens.Lens' Button Prelude.Text
button_value :: (Text -> f Text) -> Button -> f Button
button_value = (Button -> Text)
-> (Button -> Text -> Button) -> Lens Button Button Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Button' {Text
value :: Text
$sel:value:Button' :: Button -> Text
value} -> Text
value) (\s :: Button
s@Button' {} Text
a -> Button
s {$sel:value:Button' :: Text
value = Text
a} :: Button)

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

instance Prelude.Hashable Button

instance Prelude.NFData Button