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

-- | A set of actions that Amazon Lex should run if none of the other
-- conditions are met.
--
-- /See:/ 'newDefaultConditionalBranch' smart constructor.
data DefaultConditionalBranch = DefaultConditionalBranch'
  { -- | The next step in the conversation.
    DefaultConditionalBranch -> Maybe DialogState
nextStep :: Prelude.Maybe DialogState,
    DefaultConditionalBranch -> Maybe ResponseSpecification
response :: Prelude.Maybe ResponseSpecification
  }
  deriving (DefaultConditionalBranch -> DefaultConditionalBranch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultConditionalBranch -> DefaultConditionalBranch -> Bool
$c/= :: DefaultConditionalBranch -> DefaultConditionalBranch -> Bool
== :: DefaultConditionalBranch -> DefaultConditionalBranch -> Bool
$c== :: DefaultConditionalBranch -> DefaultConditionalBranch -> Bool
Prelude.Eq, ReadPrec [DefaultConditionalBranch]
ReadPrec DefaultConditionalBranch
Int -> ReadS DefaultConditionalBranch
ReadS [DefaultConditionalBranch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefaultConditionalBranch]
$creadListPrec :: ReadPrec [DefaultConditionalBranch]
readPrec :: ReadPrec DefaultConditionalBranch
$creadPrec :: ReadPrec DefaultConditionalBranch
readList :: ReadS [DefaultConditionalBranch]
$creadList :: ReadS [DefaultConditionalBranch]
readsPrec :: Int -> ReadS DefaultConditionalBranch
$creadsPrec :: Int -> ReadS DefaultConditionalBranch
Prelude.Read, Int -> DefaultConditionalBranch -> ShowS
[DefaultConditionalBranch] -> ShowS
DefaultConditionalBranch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefaultConditionalBranch] -> ShowS
$cshowList :: [DefaultConditionalBranch] -> ShowS
show :: DefaultConditionalBranch -> String
$cshow :: DefaultConditionalBranch -> String
showsPrec :: Int -> DefaultConditionalBranch -> ShowS
$cshowsPrec :: Int -> DefaultConditionalBranch -> ShowS
Prelude.Show, forall x.
Rep DefaultConditionalBranch x -> DefaultConditionalBranch
forall x.
DefaultConditionalBranch -> Rep DefaultConditionalBranch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DefaultConditionalBranch x -> DefaultConditionalBranch
$cfrom :: forall x.
DefaultConditionalBranch -> Rep DefaultConditionalBranch x
Prelude.Generic)

-- |
-- Create a value of 'DefaultConditionalBranch' 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:
--
-- 'nextStep', 'defaultConditionalBranch_nextStep' - The next step in the conversation.
--
-- 'response', 'defaultConditionalBranch_response' - Undocumented member.
newDefaultConditionalBranch ::
  DefaultConditionalBranch
newDefaultConditionalBranch :: DefaultConditionalBranch
newDefaultConditionalBranch =
  DefaultConditionalBranch'
    { $sel:nextStep:DefaultConditionalBranch' :: Maybe DialogState
nextStep =
        forall a. Maybe a
Prelude.Nothing,
      $sel:response:DefaultConditionalBranch' :: Maybe ResponseSpecification
response = forall a. Maybe a
Prelude.Nothing
    }

-- | The next step in the conversation.
defaultConditionalBranch_nextStep :: Lens.Lens' DefaultConditionalBranch (Prelude.Maybe DialogState)
defaultConditionalBranch_nextStep :: Lens' DefaultConditionalBranch (Maybe DialogState)
defaultConditionalBranch_nextStep = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultConditionalBranch' {Maybe DialogState
nextStep :: Maybe DialogState
$sel:nextStep:DefaultConditionalBranch' :: DefaultConditionalBranch -> Maybe DialogState
nextStep} -> Maybe DialogState
nextStep) (\s :: DefaultConditionalBranch
s@DefaultConditionalBranch' {} Maybe DialogState
a -> DefaultConditionalBranch
s {$sel:nextStep:DefaultConditionalBranch' :: Maybe DialogState
nextStep = Maybe DialogState
a} :: DefaultConditionalBranch)

-- | Undocumented member.
defaultConditionalBranch_response :: Lens.Lens' DefaultConditionalBranch (Prelude.Maybe ResponseSpecification)
defaultConditionalBranch_response :: Lens' DefaultConditionalBranch (Maybe ResponseSpecification)
defaultConditionalBranch_response = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultConditionalBranch' {Maybe ResponseSpecification
response :: Maybe ResponseSpecification
$sel:response:DefaultConditionalBranch' :: DefaultConditionalBranch -> Maybe ResponseSpecification
response} -> Maybe ResponseSpecification
response) (\s :: DefaultConditionalBranch
s@DefaultConditionalBranch' {} Maybe ResponseSpecification
a -> DefaultConditionalBranch
s {$sel:response:DefaultConditionalBranch' :: Maybe ResponseSpecification
response = Maybe ResponseSpecification
a} :: DefaultConditionalBranch)

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

instance Prelude.Hashable DefaultConditionalBranch where
  hashWithSalt :: Int -> DefaultConditionalBranch -> Int
hashWithSalt Int
_salt DefaultConditionalBranch' {Maybe ResponseSpecification
Maybe DialogState
response :: Maybe ResponseSpecification
nextStep :: Maybe DialogState
$sel:response:DefaultConditionalBranch' :: DefaultConditionalBranch -> Maybe ResponseSpecification
$sel:nextStep:DefaultConditionalBranch' :: DefaultConditionalBranch -> Maybe DialogState
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DialogState
nextStep
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResponseSpecification
response

instance Prelude.NFData DefaultConditionalBranch where
  rnf :: DefaultConditionalBranch -> ()
rnf DefaultConditionalBranch' {Maybe ResponseSpecification
Maybe DialogState
response :: Maybe ResponseSpecification
nextStep :: Maybe DialogState
$sel:response:DefaultConditionalBranch' :: DefaultConditionalBranch -> Maybe ResponseSpecification
$sel:nextStep:DefaultConditionalBranch' :: DefaultConditionalBranch -> Maybe DialogState
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DialogState
nextStep
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResponseSpecification
response

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