{-# 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.LexV2Models.Types.SlotValue
-- 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.LexV2Models.Types.SlotValue where

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

-- | The value to set in a slot.
--
-- /See:/ 'newSlotValue' smart constructor.
data SlotValue = SlotValue'
  { -- | The value that Amazon Lex determines for the slot. The actual value
    -- depends on the setting of the value selection strategy for the bot. You
    -- can choose to use the value entered by the user, or you can have Amazon
    -- Lex choose the first value in the @resolvedValues@ list.
    SlotValue -> Maybe Text
interpretedValue :: Prelude.Maybe Prelude.Text
  }
  deriving (SlotValue -> SlotValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotValue -> SlotValue -> Bool
$c/= :: SlotValue -> SlotValue -> Bool
== :: SlotValue -> SlotValue -> Bool
$c== :: SlotValue -> SlotValue -> Bool
Prelude.Eq, ReadPrec [SlotValue]
ReadPrec SlotValue
Int -> ReadS SlotValue
ReadS [SlotValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotValue]
$creadListPrec :: ReadPrec [SlotValue]
readPrec :: ReadPrec SlotValue
$creadPrec :: ReadPrec SlotValue
readList :: ReadS [SlotValue]
$creadList :: ReadS [SlotValue]
readsPrec :: Int -> ReadS SlotValue
$creadsPrec :: Int -> ReadS SlotValue
Prelude.Read, Int -> SlotValue -> ShowS
[SlotValue] -> ShowS
SlotValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotValue] -> ShowS
$cshowList :: [SlotValue] -> ShowS
show :: SlotValue -> String
$cshow :: SlotValue -> String
showsPrec :: Int -> SlotValue -> ShowS
$cshowsPrec :: Int -> SlotValue -> ShowS
Prelude.Show, forall x. Rep SlotValue x -> SlotValue
forall x. SlotValue -> Rep SlotValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotValue x -> SlotValue
$cfrom :: forall x. SlotValue -> Rep SlotValue x
Prelude.Generic)

-- |
-- Create a value of 'SlotValue' 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:
--
-- 'interpretedValue', 'slotValue_interpretedValue' - The value that Amazon Lex determines for the slot. The actual value
-- depends on the setting of the value selection strategy for the bot. You
-- can choose to use the value entered by the user, or you can have Amazon
-- Lex choose the first value in the @resolvedValues@ list.
newSlotValue ::
  SlotValue
newSlotValue :: SlotValue
newSlotValue =
  SlotValue' {$sel:interpretedValue:SlotValue' :: Maybe Text
interpretedValue = forall a. Maybe a
Prelude.Nothing}

-- | The value that Amazon Lex determines for the slot. The actual value
-- depends on the setting of the value selection strategy for the bot. You
-- can choose to use the value entered by the user, or you can have Amazon
-- Lex choose the first value in the @resolvedValues@ list.
slotValue_interpretedValue :: Lens.Lens' SlotValue (Prelude.Maybe Prelude.Text)
slotValue_interpretedValue :: Lens' SlotValue (Maybe Text)
slotValue_interpretedValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotValue' {Maybe Text
interpretedValue :: Maybe Text
$sel:interpretedValue:SlotValue' :: SlotValue -> Maybe Text
interpretedValue} -> Maybe Text
interpretedValue) (\s :: SlotValue
s@SlotValue' {} Maybe Text
a -> SlotValue
s {$sel:interpretedValue:SlotValue' :: Maybe Text
interpretedValue = Maybe Text
a} :: SlotValue)

instance Data.FromJSON SlotValue where
  parseJSON :: Value -> Parser SlotValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SlotValue"
      ( \Object
x ->
          Maybe Text -> SlotValue
SlotValue'
            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
"interpretedValue")
      )

instance Prelude.Hashable SlotValue where
  hashWithSalt :: Int -> SlotValue -> Int
hashWithSalt Int
_salt SlotValue' {Maybe Text
interpretedValue :: Maybe Text
$sel:interpretedValue:SlotValue' :: SlotValue -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
interpretedValue

instance Prelude.NFData SlotValue where
  rnf :: SlotValue -> ()
rnf SlotValue' {Maybe Text
interpretedValue :: Maybe Text
$sel:interpretedValue:SlotValue' :: SlotValue -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
interpretedValue

instance Data.ToJSON SlotValue where
  toJSON :: SlotValue -> Value
toJSON SlotValue' {Maybe Text
interpretedValue :: Maybe Text
$sel:interpretedValue:SlotValue' :: SlotValue -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"interpretedValue" 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
interpretedValue
          ]
      )