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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(FollowUpPrompt -> FollowUpPrompt -> Bool)
-> (FollowUpPrompt -> FollowUpPrompt -> Bool) -> Eq FollowUpPrompt
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]
(Int -> ReadS FollowUpPrompt)
-> ReadS [FollowUpPrompt]
-> ReadPrec FollowUpPrompt
-> ReadPrec [FollowUpPrompt]
-> Read 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
(Int -> FollowUpPrompt -> ShowS)
-> (FollowUpPrompt -> String)
-> ([FollowUpPrompt] -> ShowS)
-> Show FollowUpPrompt
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. FollowUpPrompt -> Rep FollowUpPrompt x)
-> (forall x. Rep FollowUpPrompt x -> FollowUpPrompt)
-> Generic FollowUpPrompt
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' :: Prompt -> Statement -> FollowUpPrompt
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 :: (Prompt -> f Prompt) -> FollowUpPrompt -> f FollowUpPrompt
followUpPrompt_prompt = (FollowUpPrompt -> Prompt)
-> (FollowUpPrompt -> Prompt -> FollowUpPrompt)
-> Lens FollowUpPrompt FollowUpPrompt Prompt 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 :: (Statement -> f Statement) -> FollowUpPrompt -> f FollowUpPrompt
followUpPrompt_rejectionStatement = (FollowUpPrompt -> Statement)
-> (FollowUpPrompt -> Statement -> FollowUpPrompt)
-> Lens FollowUpPrompt FollowUpPrompt Statement Statement
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 Core.FromJSON FollowUpPrompt where
  parseJSON :: Value -> Parser FollowUpPrompt
parseJSON =
    String
-> (Object -> Parser FollowUpPrompt)
-> Value
-> Parser FollowUpPrompt
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FollowUpPrompt"
      ( \Object
x ->
          Prompt -> Statement -> FollowUpPrompt
FollowUpPrompt'
            (Prompt -> Statement -> FollowUpPrompt)
-> Parser Prompt -> Parser (Statement -> FollowUpPrompt)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Prompt
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"prompt")
            Parser (Statement -> FollowUpPrompt)
-> Parser Statement -> Parser FollowUpPrompt
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Statement
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"rejectionStatement")
      )

instance Prelude.Hashable FollowUpPrompt

instance Prelude.NFData FollowUpPrompt

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"prompt" Text -> Prompt -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Prompt
prompt),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"rejectionStatement" Text -> Statement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Statement
rejectionStatement)
          ]
      )