{-# 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.LexModels.Types.FollowUpPrompt
-- 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.LexModels.Types.FollowUpPrompt where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexModels.Types.Prompt
import Amazonka.LexModels.Types.Statement
import qualified Amazonka.Prelude as Prelude

-- | A prompt for additional activity after an intent is fulfilled. For
-- example, after the @OrderPizza@ intent is fulfilled, you might prompt
-- the user to find out whether the user wants to order drinks.
--
-- /See:/ 'newFollowUpPrompt' smart constructor.
data FollowUpPrompt = FollowUpPrompt'
  { -- | Prompts for information from the user.
    FollowUpPrompt -> Prompt
prompt :: Prompt,
    -- | If the user answers \"no\" to the question defined in the @prompt@
    -- field, Amazon Lex responds with this statement to acknowledge that the
    -- intent was canceled.
    FollowUpPrompt -> Statement
rejectionStatement :: Statement
  }
  deriving (FollowUpPrompt -> FollowUpPrompt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FollowUpPrompt -> FollowUpPrompt -> Bool
$c/= :: FollowUpPrompt -> FollowUpPrompt -> Bool
== :: FollowUpPrompt -> FollowUpPrompt -> Bool
$c== :: FollowUpPrompt -> FollowUpPrompt -> Bool
Prelude.Eq, ReadPrec [FollowUpPrompt]
ReadPrec FollowUpPrompt
Int -> ReadS FollowUpPrompt
ReadS [FollowUpPrompt]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FollowUpPrompt]
$creadListPrec :: ReadPrec [FollowUpPrompt]
readPrec :: ReadPrec FollowUpPrompt
$creadPrec :: ReadPrec FollowUpPrompt
readList :: ReadS [FollowUpPrompt]
$creadList :: ReadS [FollowUpPrompt]
readsPrec :: Int -> ReadS FollowUpPrompt
$creadsPrec :: Int -> ReadS FollowUpPrompt
Prelude.Read, Int -> FollowUpPrompt -> ShowS
[FollowUpPrompt] -> ShowS
FollowUpPrompt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FollowUpPrompt] -> ShowS
$cshowList :: [FollowUpPrompt] -> ShowS
show :: FollowUpPrompt -> String
$cshow :: FollowUpPrompt -> String
showsPrec :: Int -> FollowUpPrompt -> ShowS
$cshowsPrec :: Int -> FollowUpPrompt -> ShowS
Prelude.Show, forall x. Rep FollowUpPrompt x -> FollowUpPrompt
forall x. FollowUpPrompt -> Rep FollowUpPrompt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FollowUpPrompt x -> FollowUpPrompt
$cfrom :: forall x. FollowUpPrompt -> Rep FollowUpPrompt x
Prelude.Generic)

-- |
-- Create a value of 'FollowUpPrompt' 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:
--
-- 'prompt', 'followUpPrompt_prompt' - Prompts for information from the user.
--
-- 'rejectionStatement', 'followUpPrompt_rejectionStatement' - If the user answers \"no\" to the question defined in the @prompt@
-- field, Amazon Lex responds with this statement to acknowledge that the
-- intent was canceled.
newFollowUpPrompt ::
  -- | 'prompt'
  Prompt ->
  -- | 'rejectionStatement'
  Statement ->
  FollowUpPrompt
newFollowUpPrompt :: Prompt -> Statement -> FollowUpPrompt
newFollowUpPrompt Prompt
pPrompt_ Statement
pRejectionStatement_ =
  FollowUpPrompt'
    { $sel:prompt:FollowUpPrompt' :: Prompt
prompt = Prompt
pPrompt_,
      $sel:rejectionStatement:FollowUpPrompt' :: Statement
rejectionStatement = Statement
pRejectionStatement_
    }

-- | Prompts for information from the user.
followUpPrompt_prompt :: Lens.Lens' FollowUpPrompt Prompt
followUpPrompt_prompt :: Lens' FollowUpPrompt Prompt
followUpPrompt_prompt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FollowUpPrompt' {Prompt
prompt :: Prompt
$sel:prompt:FollowUpPrompt' :: FollowUpPrompt -> Prompt
prompt} -> Prompt
prompt) (\s :: FollowUpPrompt
s@FollowUpPrompt' {} Prompt
a -> FollowUpPrompt
s {$sel:prompt:FollowUpPrompt' :: Prompt
prompt = Prompt
a} :: FollowUpPrompt)

-- | If the user answers \"no\" to the question defined in the @prompt@
-- field, Amazon Lex responds with this statement to acknowledge that the
-- intent was canceled.
followUpPrompt_rejectionStatement :: Lens.Lens' FollowUpPrompt Statement
followUpPrompt_rejectionStatement :: Lens' FollowUpPrompt Statement
followUpPrompt_rejectionStatement = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FollowUpPrompt' {Statement
rejectionStatement :: Statement
$sel:rejectionStatement:FollowUpPrompt' :: FollowUpPrompt -> Statement
rejectionStatement} -> Statement
rejectionStatement) (\s :: FollowUpPrompt
s@FollowUpPrompt' {} Statement
a -> FollowUpPrompt
s {$sel:rejectionStatement:FollowUpPrompt' :: Statement
rejectionStatement = Statement
a} :: FollowUpPrompt)

instance Data.FromJSON FollowUpPrompt where
  parseJSON :: Value -> Parser FollowUpPrompt
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FollowUpPrompt"
      ( \Object
x ->
          Prompt -> Statement -> FollowUpPrompt
FollowUpPrompt'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"prompt")
            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
"rejectionStatement")
      )

instance Prelude.Hashable FollowUpPrompt where
  hashWithSalt :: Int -> FollowUpPrompt -> Int
hashWithSalt Int
_salt FollowUpPrompt' {Prompt
Statement
rejectionStatement :: Statement
prompt :: Prompt
$sel:rejectionStatement:FollowUpPrompt' :: FollowUpPrompt -> Statement
$sel:prompt:FollowUpPrompt' :: FollowUpPrompt -> Prompt
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Prompt
prompt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Statement
rejectionStatement

instance Prelude.NFData FollowUpPrompt where
  rnf :: FollowUpPrompt -> ()
rnf FollowUpPrompt' {Prompt
Statement
rejectionStatement :: Statement
prompt :: Prompt
$sel:rejectionStatement:FollowUpPrompt' :: FollowUpPrompt -> Statement
$sel:prompt:FollowUpPrompt' :: FollowUpPrompt -> Prompt
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Prompt
prompt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Statement
rejectionStatement

instance Data.ToJSON FollowUpPrompt where
  toJSON :: FollowUpPrompt -> Value
toJSON FollowUpPrompt' {Prompt
Statement
rejectionStatement :: Statement
prompt :: Prompt
$sel:rejectionStatement:FollowUpPrompt' :: FollowUpPrompt -> Statement
$sel:prompt:FollowUpPrompt' :: FollowUpPrompt -> Prompt
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"prompt" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Prompt
prompt),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"rejectionStatement" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Statement
rejectionStatement)
          ]
      )