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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.ConditionalSpecification
import Amazonka.LexV2Models.Types.DialogState
import Amazonka.LexV2Models.Types.ResponseSpecification
import qualified Amazonka.Prelude as Prelude

-- | Provides a statement the Amazon Lex conveys to the user when the intent
-- is successfully fulfilled.
--
-- /See:/ 'newIntentClosingSetting' smart constructor.
data IntentClosingSetting = IntentClosingSetting'
  { -- | Specifies whether an intent\'s closing response is used. When this field
    -- is false, the closing response isn\'t sent to the user. If the @active@
    -- field isn\'t specified, the default is true.
    IntentClosingSetting -> Maybe Bool
active :: Prelude.Maybe Prelude.Bool,
    -- | The response that Amazon Lex sends to the user when the intent is
    -- complete.
    IntentClosingSetting -> Maybe ResponseSpecification
closingResponse :: Prelude.Maybe ResponseSpecification,
    -- | A list of conditional branches associated with the intent\'s closing
    -- response. These branches are executed when the @nextStep@ attribute is
    -- set to @EvalutateConditional@.
    IntentClosingSetting -> Maybe ConditionalSpecification
conditional :: Prelude.Maybe ConditionalSpecification,
    -- | Specifies the next step that the bot executes after playing the
    -- intent\'s closing response.
    IntentClosingSetting -> Maybe DialogState
nextStep :: Prelude.Maybe DialogState
  }
  deriving (IntentClosingSetting -> IntentClosingSetting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntentClosingSetting -> IntentClosingSetting -> Bool
$c/= :: IntentClosingSetting -> IntentClosingSetting -> Bool
== :: IntentClosingSetting -> IntentClosingSetting -> Bool
$c== :: IntentClosingSetting -> IntentClosingSetting -> Bool
Prelude.Eq, ReadPrec [IntentClosingSetting]
ReadPrec IntentClosingSetting
Int -> ReadS IntentClosingSetting
ReadS [IntentClosingSetting]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IntentClosingSetting]
$creadListPrec :: ReadPrec [IntentClosingSetting]
readPrec :: ReadPrec IntentClosingSetting
$creadPrec :: ReadPrec IntentClosingSetting
readList :: ReadS [IntentClosingSetting]
$creadList :: ReadS [IntentClosingSetting]
readsPrec :: Int -> ReadS IntentClosingSetting
$creadsPrec :: Int -> ReadS IntentClosingSetting
Prelude.Read, Int -> IntentClosingSetting -> ShowS
[IntentClosingSetting] -> ShowS
IntentClosingSetting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntentClosingSetting] -> ShowS
$cshowList :: [IntentClosingSetting] -> ShowS
show :: IntentClosingSetting -> String
$cshow :: IntentClosingSetting -> String
showsPrec :: Int -> IntentClosingSetting -> ShowS
$cshowsPrec :: Int -> IntentClosingSetting -> ShowS
Prelude.Show, forall x. Rep IntentClosingSetting x -> IntentClosingSetting
forall x. IntentClosingSetting -> Rep IntentClosingSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntentClosingSetting x -> IntentClosingSetting
$cfrom :: forall x. IntentClosingSetting -> Rep IntentClosingSetting x
Prelude.Generic)

-- |
-- Create a value of 'IntentClosingSetting' 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:
--
-- 'active', 'intentClosingSetting_active' - Specifies whether an intent\'s closing response is used. When this field
-- is false, the closing response isn\'t sent to the user. If the @active@
-- field isn\'t specified, the default is true.
--
-- 'closingResponse', 'intentClosingSetting_closingResponse' - The response that Amazon Lex sends to the user when the intent is
-- complete.
--
-- 'conditional', 'intentClosingSetting_conditional' - A list of conditional branches associated with the intent\'s closing
-- response. These branches are executed when the @nextStep@ attribute is
-- set to @EvalutateConditional@.
--
-- 'nextStep', 'intentClosingSetting_nextStep' - Specifies the next step that the bot executes after playing the
-- intent\'s closing response.
newIntentClosingSetting ::
  IntentClosingSetting
newIntentClosingSetting :: IntentClosingSetting
newIntentClosingSetting =
  IntentClosingSetting'
    { $sel:active:IntentClosingSetting' :: Maybe Bool
active = forall a. Maybe a
Prelude.Nothing,
      $sel:closingResponse:IntentClosingSetting' :: Maybe ResponseSpecification
closingResponse = forall a. Maybe a
Prelude.Nothing,
      $sel:conditional:IntentClosingSetting' :: Maybe ConditionalSpecification
conditional = forall a. Maybe a
Prelude.Nothing,
      $sel:nextStep:IntentClosingSetting' :: Maybe DialogState
nextStep = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether an intent\'s closing response is used. When this field
-- is false, the closing response isn\'t sent to the user. If the @active@
-- field isn\'t specified, the default is true.
intentClosingSetting_active :: Lens.Lens' IntentClosingSetting (Prelude.Maybe Prelude.Bool)
intentClosingSetting_active :: Lens' IntentClosingSetting (Maybe Bool)
intentClosingSetting_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntentClosingSetting' {Maybe Bool
active :: Maybe Bool
$sel:active:IntentClosingSetting' :: IntentClosingSetting -> Maybe Bool
active} -> Maybe Bool
active) (\s :: IntentClosingSetting
s@IntentClosingSetting' {} Maybe Bool
a -> IntentClosingSetting
s {$sel:active:IntentClosingSetting' :: Maybe Bool
active = Maybe Bool
a} :: IntentClosingSetting)

-- | The response that Amazon Lex sends to the user when the intent is
-- complete.
intentClosingSetting_closingResponse :: Lens.Lens' IntentClosingSetting (Prelude.Maybe ResponseSpecification)
intentClosingSetting_closingResponse :: Lens' IntentClosingSetting (Maybe ResponseSpecification)
intentClosingSetting_closingResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntentClosingSetting' {Maybe ResponseSpecification
closingResponse :: Maybe ResponseSpecification
$sel:closingResponse:IntentClosingSetting' :: IntentClosingSetting -> Maybe ResponseSpecification
closingResponse} -> Maybe ResponseSpecification
closingResponse) (\s :: IntentClosingSetting
s@IntentClosingSetting' {} Maybe ResponseSpecification
a -> IntentClosingSetting
s {$sel:closingResponse:IntentClosingSetting' :: Maybe ResponseSpecification
closingResponse = Maybe ResponseSpecification
a} :: IntentClosingSetting)

-- | A list of conditional branches associated with the intent\'s closing
-- response. These branches are executed when the @nextStep@ attribute is
-- set to @EvalutateConditional@.
intentClosingSetting_conditional :: Lens.Lens' IntentClosingSetting (Prelude.Maybe ConditionalSpecification)
intentClosingSetting_conditional :: Lens' IntentClosingSetting (Maybe ConditionalSpecification)
intentClosingSetting_conditional = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntentClosingSetting' {Maybe ConditionalSpecification
conditional :: Maybe ConditionalSpecification
$sel:conditional:IntentClosingSetting' :: IntentClosingSetting -> Maybe ConditionalSpecification
conditional} -> Maybe ConditionalSpecification
conditional) (\s :: IntentClosingSetting
s@IntentClosingSetting' {} Maybe ConditionalSpecification
a -> IntentClosingSetting
s {$sel:conditional:IntentClosingSetting' :: Maybe ConditionalSpecification
conditional = Maybe ConditionalSpecification
a} :: IntentClosingSetting)

-- | Specifies the next step that the bot executes after playing the
-- intent\'s closing response.
intentClosingSetting_nextStep :: Lens.Lens' IntentClosingSetting (Prelude.Maybe DialogState)
intentClosingSetting_nextStep :: Lens' IntentClosingSetting (Maybe DialogState)
intentClosingSetting_nextStep = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntentClosingSetting' {Maybe DialogState
nextStep :: Maybe DialogState
$sel:nextStep:IntentClosingSetting' :: IntentClosingSetting -> Maybe DialogState
nextStep} -> Maybe DialogState
nextStep) (\s :: IntentClosingSetting
s@IntentClosingSetting' {} Maybe DialogState
a -> IntentClosingSetting
s {$sel:nextStep:IntentClosingSetting' :: Maybe DialogState
nextStep = Maybe DialogState
a} :: IntentClosingSetting)

instance Data.FromJSON IntentClosingSetting where
  parseJSON :: Value -> Parser IntentClosingSetting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IntentClosingSetting"
      ( \Object
x ->
          Maybe Bool
-> Maybe ResponseSpecification
-> Maybe ConditionalSpecification
-> Maybe DialogState
-> IntentClosingSetting
IntentClosingSetting'
            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
"active")
            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
"closingResponse")
            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
"conditional")
            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
"nextStep")
      )

instance Prelude.Hashable IntentClosingSetting where
  hashWithSalt :: Int -> IntentClosingSetting -> Int
hashWithSalt Int
_salt IntentClosingSetting' {Maybe Bool
Maybe ResponseSpecification
Maybe DialogState
Maybe ConditionalSpecification
nextStep :: Maybe DialogState
conditional :: Maybe ConditionalSpecification
closingResponse :: Maybe ResponseSpecification
active :: Maybe Bool
$sel:nextStep:IntentClosingSetting' :: IntentClosingSetting -> Maybe DialogState
$sel:conditional:IntentClosingSetting' :: IntentClosingSetting -> Maybe ConditionalSpecification
$sel:closingResponse:IntentClosingSetting' :: IntentClosingSetting -> Maybe ResponseSpecification
$sel:active:IntentClosingSetting' :: IntentClosingSetting -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
active
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResponseSpecification
closingResponse
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConditionalSpecification
conditional
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DialogState
nextStep

instance Prelude.NFData IntentClosingSetting where
  rnf :: IntentClosingSetting -> ()
rnf IntentClosingSetting' {Maybe Bool
Maybe ResponseSpecification
Maybe DialogState
Maybe ConditionalSpecification
nextStep :: Maybe DialogState
conditional :: Maybe ConditionalSpecification
closingResponse :: Maybe ResponseSpecification
active :: Maybe Bool
$sel:nextStep:IntentClosingSetting' :: IntentClosingSetting -> Maybe DialogState
$sel:conditional:IntentClosingSetting' :: IntentClosingSetting -> Maybe ConditionalSpecification
$sel:closingResponse:IntentClosingSetting' :: IntentClosingSetting -> Maybe ResponseSpecification
$sel:active:IntentClosingSetting' :: IntentClosingSetting -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
active
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResponseSpecification
closingResponse
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConditionalSpecification
conditional
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DialogState
nextStep

instance Data.ToJSON IntentClosingSetting where
  toJSON :: IntentClosingSetting -> Value
toJSON IntentClosingSetting' {Maybe Bool
Maybe ResponseSpecification
Maybe DialogState
Maybe ConditionalSpecification
nextStep :: Maybe DialogState
conditional :: Maybe ConditionalSpecification
closingResponse :: Maybe ResponseSpecification
active :: Maybe Bool
$sel:nextStep:IntentClosingSetting' :: IntentClosingSetting -> Maybe DialogState
$sel:conditional:IntentClosingSetting' :: IntentClosingSetting -> Maybe ConditionalSpecification
$sel:closingResponse:IntentClosingSetting' :: IntentClosingSetting -> Maybe ResponseSpecification
$sel:active:IntentClosingSetting' :: IntentClosingSetting -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"active" 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 Bool
active,
            (Key
"closingResponse" 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 ResponseSpecification
closingResponse,
            (Key
"conditional" 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 ConditionalSpecification
conditional,
            (Key
"nextStep" 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 DialogState
nextStep
          ]
      )