{-# 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.WaitAndContinueSpecification
-- 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.WaitAndContinueSpecification 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.ResponseSpecification
import Amazonka.LexV2Models.Types.StillWaitingResponseSpecification
import qualified Amazonka.Prelude as Prelude

-- | Specifies the prompts that Amazon Lex uses while a bot is waiting for
-- customer input.
--
-- /See:/ 'newWaitAndContinueSpecification' smart constructor.
data WaitAndContinueSpecification = WaitAndContinueSpecification'
  { -- | Specifies whether the bot will wait for a user to respond. When this
    -- field is false, wait and continue responses for a slot aren\'t used. If
    -- the @active@ field isn\'t specified, the default is true.
    WaitAndContinueSpecification -> Maybe Bool
active :: Prelude.Maybe Prelude.Bool,
    -- | A response that Amazon Lex sends periodically to the user to indicate
    -- that the bot is still waiting for input from the user.
    WaitAndContinueSpecification
-> Maybe StillWaitingResponseSpecification
stillWaitingResponse :: Prelude.Maybe StillWaitingResponseSpecification,
    -- | The response that Amazon Lex sends to indicate that the bot is waiting
    -- for the conversation to continue.
    WaitAndContinueSpecification -> ResponseSpecification
waitingResponse :: ResponseSpecification,
    -- | The response that Amazon Lex sends to indicate that the bot is ready to
    -- continue the conversation.
    WaitAndContinueSpecification -> ResponseSpecification
continueResponse :: ResponseSpecification
  }
  deriving (WaitAndContinueSpecification
-> WaitAndContinueSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WaitAndContinueSpecification
-> WaitAndContinueSpecification -> Bool
$c/= :: WaitAndContinueSpecification
-> WaitAndContinueSpecification -> Bool
== :: WaitAndContinueSpecification
-> WaitAndContinueSpecification -> Bool
$c== :: WaitAndContinueSpecification
-> WaitAndContinueSpecification -> Bool
Prelude.Eq, ReadPrec [WaitAndContinueSpecification]
ReadPrec WaitAndContinueSpecification
Int -> ReadS WaitAndContinueSpecification
ReadS [WaitAndContinueSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WaitAndContinueSpecification]
$creadListPrec :: ReadPrec [WaitAndContinueSpecification]
readPrec :: ReadPrec WaitAndContinueSpecification
$creadPrec :: ReadPrec WaitAndContinueSpecification
readList :: ReadS [WaitAndContinueSpecification]
$creadList :: ReadS [WaitAndContinueSpecification]
readsPrec :: Int -> ReadS WaitAndContinueSpecification
$creadsPrec :: Int -> ReadS WaitAndContinueSpecification
Prelude.Read, Int -> WaitAndContinueSpecification -> ShowS
[WaitAndContinueSpecification] -> ShowS
WaitAndContinueSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WaitAndContinueSpecification] -> ShowS
$cshowList :: [WaitAndContinueSpecification] -> ShowS
show :: WaitAndContinueSpecification -> String
$cshow :: WaitAndContinueSpecification -> String
showsPrec :: Int -> WaitAndContinueSpecification -> ShowS
$cshowsPrec :: Int -> WaitAndContinueSpecification -> ShowS
Prelude.Show, forall x.
Rep WaitAndContinueSpecification x -> WaitAndContinueSpecification
forall x.
WaitAndContinueSpecification -> Rep WaitAndContinueSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep WaitAndContinueSpecification x -> WaitAndContinueSpecification
$cfrom :: forall x.
WaitAndContinueSpecification -> Rep WaitAndContinueSpecification x
Prelude.Generic)

-- |
-- Create a value of 'WaitAndContinueSpecification' 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', 'waitAndContinueSpecification_active' - Specifies whether the bot will wait for a user to respond. When this
-- field is false, wait and continue responses for a slot aren\'t used. If
-- the @active@ field isn\'t specified, the default is true.
--
-- 'stillWaitingResponse', 'waitAndContinueSpecification_stillWaitingResponse' - A response that Amazon Lex sends periodically to the user to indicate
-- that the bot is still waiting for input from the user.
--
-- 'waitingResponse', 'waitAndContinueSpecification_waitingResponse' - The response that Amazon Lex sends to indicate that the bot is waiting
-- for the conversation to continue.
--
-- 'continueResponse', 'waitAndContinueSpecification_continueResponse' - The response that Amazon Lex sends to indicate that the bot is ready to
-- continue the conversation.
newWaitAndContinueSpecification ::
  -- | 'waitingResponse'
  ResponseSpecification ->
  -- | 'continueResponse'
  ResponseSpecification ->
  WaitAndContinueSpecification
newWaitAndContinueSpecification :: ResponseSpecification
-> ResponseSpecification -> WaitAndContinueSpecification
newWaitAndContinueSpecification
  ResponseSpecification
pWaitingResponse_
  ResponseSpecification
pContinueResponse_ =
    WaitAndContinueSpecification'
      { $sel:active:WaitAndContinueSpecification' :: Maybe Bool
active =
          forall a. Maybe a
Prelude.Nothing,
        $sel:stillWaitingResponse:WaitAndContinueSpecification' :: Maybe StillWaitingResponseSpecification
stillWaitingResponse = forall a. Maybe a
Prelude.Nothing,
        $sel:waitingResponse:WaitAndContinueSpecification' :: ResponseSpecification
waitingResponse = ResponseSpecification
pWaitingResponse_,
        $sel:continueResponse:WaitAndContinueSpecification' :: ResponseSpecification
continueResponse = ResponseSpecification
pContinueResponse_
      }

-- | Specifies whether the bot will wait for a user to respond. When this
-- field is false, wait and continue responses for a slot aren\'t used. If
-- the @active@ field isn\'t specified, the default is true.
waitAndContinueSpecification_active :: Lens.Lens' WaitAndContinueSpecification (Prelude.Maybe Prelude.Bool)
waitAndContinueSpecification_active :: Lens' WaitAndContinueSpecification (Maybe Bool)
waitAndContinueSpecification_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitAndContinueSpecification' {Maybe Bool
active :: Maybe Bool
$sel:active:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> Maybe Bool
active} -> Maybe Bool
active) (\s :: WaitAndContinueSpecification
s@WaitAndContinueSpecification' {} Maybe Bool
a -> WaitAndContinueSpecification
s {$sel:active:WaitAndContinueSpecification' :: Maybe Bool
active = Maybe Bool
a} :: WaitAndContinueSpecification)

-- | A response that Amazon Lex sends periodically to the user to indicate
-- that the bot is still waiting for input from the user.
waitAndContinueSpecification_stillWaitingResponse :: Lens.Lens' WaitAndContinueSpecification (Prelude.Maybe StillWaitingResponseSpecification)
waitAndContinueSpecification_stillWaitingResponse :: Lens'
  WaitAndContinueSpecification
  (Maybe StillWaitingResponseSpecification)
waitAndContinueSpecification_stillWaitingResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitAndContinueSpecification' {Maybe StillWaitingResponseSpecification
stillWaitingResponse :: Maybe StillWaitingResponseSpecification
$sel:stillWaitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification
-> Maybe StillWaitingResponseSpecification
stillWaitingResponse} -> Maybe StillWaitingResponseSpecification
stillWaitingResponse) (\s :: WaitAndContinueSpecification
s@WaitAndContinueSpecification' {} Maybe StillWaitingResponseSpecification
a -> WaitAndContinueSpecification
s {$sel:stillWaitingResponse:WaitAndContinueSpecification' :: Maybe StillWaitingResponseSpecification
stillWaitingResponse = Maybe StillWaitingResponseSpecification
a} :: WaitAndContinueSpecification)

-- | The response that Amazon Lex sends to indicate that the bot is waiting
-- for the conversation to continue.
waitAndContinueSpecification_waitingResponse :: Lens.Lens' WaitAndContinueSpecification ResponseSpecification
waitAndContinueSpecification_waitingResponse :: Lens' WaitAndContinueSpecification ResponseSpecification
waitAndContinueSpecification_waitingResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitAndContinueSpecification' {ResponseSpecification
waitingResponse :: ResponseSpecification
$sel:waitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
waitingResponse} -> ResponseSpecification
waitingResponse) (\s :: WaitAndContinueSpecification
s@WaitAndContinueSpecification' {} ResponseSpecification
a -> WaitAndContinueSpecification
s {$sel:waitingResponse:WaitAndContinueSpecification' :: ResponseSpecification
waitingResponse = ResponseSpecification
a} :: WaitAndContinueSpecification)

-- | The response that Amazon Lex sends to indicate that the bot is ready to
-- continue the conversation.
waitAndContinueSpecification_continueResponse :: Lens.Lens' WaitAndContinueSpecification ResponseSpecification
waitAndContinueSpecification_continueResponse :: Lens' WaitAndContinueSpecification ResponseSpecification
waitAndContinueSpecification_continueResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitAndContinueSpecification' {ResponseSpecification
continueResponse :: ResponseSpecification
$sel:continueResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
continueResponse} -> ResponseSpecification
continueResponse) (\s :: WaitAndContinueSpecification
s@WaitAndContinueSpecification' {} ResponseSpecification
a -> WaitAndContinueSpecification
s {$sel:continueResponse:WaitAndContinueSpecification' :: ResponseSpecification
continueResponse = ResponseSpecification
a} :: WaitAndContinueSpecification)

instance Data.FromJSON WaitAndContinueSpecification where
  parseJSON :: Value -> Parser WaitAndContinueSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WaitAndContinueSpecification"
      ( \Object
x ->
          Maybe Bool
-> Maybe StillWaitingResponseSpecification
-> ResponseSpecification
-> ResponseSpecification
-> WaitAndContinueSpecification
WaitAndContinueSpecification'
            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
"stillWaitingResponse")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"waitingResponse")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"continueResponse")
      )

instance
  Prelude.Hashable
    WaitAndContinueSpecification
  where
  hashWithSalt :: Int -> WaitAndContinueSpecification -> Int
hashWithSalt Int
_salt WaitAndContinueSpecification' {Maybe Bool
Maybe StillWaitingResponseSpecification
ResponseSpecification
continueResponse :: ResponseSpecification
waitingResponse :: ResponseSpecification
stillWaitingResponse :: Maybe StillWaitingResponseSpecification
active :: Maybe Bool
$sel:continueResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
$sel:waitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
$sel:stillWaitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification
-> Maybe StillWaitingResponseSpecification
$sel:active:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> 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 StillWaitingResponseSpecification
stillWaitingResponse
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResponseSpecification
waitingResponse
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResponseSpecification
continueResponse

instance Prelude.NFData WaitAndContinueSpecification where
  rnf :: WaitAndContinueSpecification -> ()
rnf WaitAndContinueSpecification' {Maybe Bool
Maybe StillWaitingResponseSpecification
ResponseSpecification
continueResponse :: ResponseSpecification
waitingResponse :: ResponseSpecification
stillWaitingResponse :: Maybe StillWaitingResponseSpecification
active :: Maybe Bool
$sel:continueResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
$sel:waitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
$sel:stillWaitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification
-> Maybe StillWaitingResponseSpecification
$sel:active:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> 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 StillWaitingResponseSpecification
stillWaitingResponse
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResponseSpecification
waitingResponse
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResponseSpecification
continueResponse

instance Data.ToJSON WaitAndContinueSpecification where
  toJSON :: WaitAndContinueSpecification -> Value
toJSON WaitAndContinueSpecification' {Maybe Bool
Maybe StillWaitingResponseSpecification
ResponseSpecification
continueResponse :: ResponseSpecification
waitingResponse :: ResponseSpecification
stillWaitingResponse :: Maybe StillWaitingResponseSpecification
active :: Maybe Bool
$sel:continueResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
$sel:waitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> ResponseSpecification
$sel:stillWaitingResponse:WaitAndContinueSpecification' :: WaitAndContinueSpecification
-> Maybe StillWaitingResponseSpecification
$sel:active:WaitAndContinueSpecification' :: WaitAndContinueSpecification -> 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
"stillWaitingResponse" 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 StillWaitingResponseSpecification
stillWaitingResponse,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"waitingResponse" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResponseSpecification
waitingResponse),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"continueResponse" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResponseSpecification
continueResponse)
          ]
      )