{-# 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.FulfillmentStartResponseSpecification
-- 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.FulfillmentStartResponseSpecification 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.MessageGroup
import qualified Amazonka.Prelude as Prelude

-- | Provides settings for a message that is sent to the user when a
-- fulfillment Lambda function starts running.
--
-- /See:/ 'newFulfillmentStartResponseSpecification' smart constructor.
data FulfillmentStartResponseSpecification = FulfillmentStartResponseSpecification'
  { -- | Determines whether the user can interrupt the start message while it is
    -- playing.
    FulfillmentStartResponseSpecification -> Maybe Bool
allowInterrupt :: Prelude.Maybe Prelude.Bool,
    -- | The delay between when the Lambda fulfillment function starts running
    -- and the start message is played. If the Lambda function returns before
    -- the delay is over, the start message isn\'t played.
    FulfillmentStartResponseSpecification -> Natural
delayInSeconds :: Prelude.Natural,
    -- | One to 5 message groups that contain start messages. Amazon Lex chooses
    -- one of the messages to play to the user.
    FulfillmentStartResponseSpecification -> NonEmpty MessageGroup
messageGroups :: Prelude.NonEmpty MessageGroup
  }
  deriving (FulfillmentStartResponseSpecification
-> FulfillmentStartResponseSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FulfillmentStartResponseSpecification
-> FulfillmentStartResponseSpecification -> Bool
$c/= :: FulfillmentStartResponseSpecification
-> FulfillmentStartResponseSpecification -> Bool
== :: FulfillmentStartResponseSpecification
-> FulfillmentStartResponseSpecification -> Bool
$c== :: FulfillmentStartResponseSpecification
-> FulfillmentStartResponseSpecification -> Bool
Prelude.Eq, ReadPrec [FulfillmentStartResponseSpecification]
ReadPrec FulfillmentStartResponseSpecification
Int -> ReadS FulfillmentStartResponseSpecification
ReadS [FulfillmentStartResponseSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FulfillmentStartResponseSpecification]
$creadListPrec :: ReadPrec [FulfillmentStartResponseSpecification]
readPrec :: ReadPrec FulfillmentStartResponseSpecification
$creadPrec :: ReadPrec FulfillmentStartResponseSpecification
readList :: ReadS [FulfillmentStartResponseSpecification]
$creadList :: ReadS [FulfillmentStartResponseSpecification]
readsPrec :: Int -> ReadS FulfillmentStartResponseSpecification
$creadsPrec :: Int -> ReadS FulfillmentStartResponseSpecification
Prelude.Read, Int -> FulfillmentStartResponseSpecification -> ShowS
[FulfillmentStartResponseSpecification] -> ShowS
FulfillmentStartResponseSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FulfillmentStartResponseSpecification] -> ShowS
$cshowList :: [FulfillmentStartResponseSpecification] -> ShowS
show :: FulfillmentStartResponseSpecification -> String
$cshow :: FulfillmentStartResponseSpecification -> String
showsPrec :: Int -> FulfillmentStartResponseSpecification -> ShowS
$cshowsPrec :: Int -> FulfillmentStartResponseSpecification -> ShowS
Prelude.Show, forall x.
Rep FulfillmentStartResponseSpecification x
-> FulfillmentStartResponseSpecification
forall x.
FulfillmentStartResponseSpecification
-> Rep FulfillmentStartResponseSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FulfillmentStartResponseSpecification x
-> FulfillmentStartResponseSpecification
$cfrom :: forall x.
FulfillmentStartResponseSpecification
-> Rep FulfillmentStartResponseSpecification x
Prelude.Generic)

-- |
-- Create a value of 'FulfillmentStartResponseSpecification' 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:
--
-- 'allowInterrupt', 'fulfillmentStartResponseSpecification_allowInterrupt' - Determines whether the user can interrupt the start message while it is
-- playing.
--
-- 'delayInSeconds', 'fulfillmentStartResponseSpecification_delayInSeconds' - The delay between when the Lambda fulfillment function starts running
-- and the start message is played. If the Lambda function returns before
-- the delay is over, the start message isn\'t played.
--
-- 'messageGroups', 'fulfillmentStartResponseSpecification_messageGroups' - One to 5 message groups that contain start messages. Amazon Lex chooses
-- one of the messages to play to the user.
newFulfillmentStartResponseSpecification ::
  -- | 'delayInSeconds'
  Prelude.Natural ->
  -- | 'messageGroups'
  Prelude.NonEmpty MessageGroup ->
  FulfillmentStartResponseSpecification
newFulfillmentStartResponseSpecification :: Natural
-> NonEmpty MessageGroup -> FulfillmentStartResponseSpecification
newFulfillmentStartResponseSpecification
  Natural
pDelayInSeconds_
  NonEmpty MessageGroup
pMessageGroups_ =
    FulfillmentStartResponseSpecification'
      { $sel:allowInterrupt:FulfillmentStartResponseSpecification' :: Maybe Bool
allowInterrupt =
          forall a. Maybe a
Prelude.Nothing,
        $sel:delayInSeconds:FulfillmentStartResponseSpecification' :: Natural
delayInSeconds = Natural
pDelayInSeconds_,
        $sel:messageGroups:FulfillmentStartResponseSpecification' :: NonEmpty MessageGroup
messageGroups =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            forall t b. AReview t b -> b -> t
Lens.# NonEmpty MessageGroup
pMessageGroups_
      }

-- | Determines whether the user can interrupt the start message while it is
-- playing.
fulfillmentStartResponseSpecification_allowInterrupt :: Lens.Lens' FulfillmentStartResponseSpecification (Prelude.Maybe Prelude.Bool)
fulfillmentStartResponseSpecification_allowInterrupt :: Lens' FulfillmentStartResponseSpecification (Maybe Bool)
fulfillmentStartResponseSpecification_allowInterrupt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentStartResponseSpecification' {Maybe Bool
allowInterrupt :: Maybe Bool
$sel:allowInterrupt:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Maybe Bool
allowInterrupt} -> Maybe Bool
allowInterrupt) (\s :: FulfillmentStartResponseSpecification
s@FulfillmentStartResponseSpecification' {} Maybe Bool
a -> FulfillmentStartResponseSpecification
s {$sel:allowInterrupt:FulfillmentStartResponseSpecification' :: Maybe Bool
allowInterrupt = Maybe Bool
a} :: FulfillmentStartResponseSpecification)

-- | The delay between when the Lambda fulfillment function starts running
-- and the start message is played. If the Lambda function returns before
-- the delay is over, the start message isn\'t played.
fulfillmentStartResponseSpecification_delayInSeconds :: Lens.Lens' FulfillmentStartResponseSpecification Prelude.Natural
fulfillmentStartResponseSpecification_delayInSeconds :: Lens' FulfillmentStartResponseSpecification Natural
fulfillmentStartResponseSpecification_delayInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentStartResponseSpecification' {Natural
delayInSeconds :: Natural
$sel:delayInSeconds:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Natural
delayInSeconds} -> Natural
delayInSeconds) (\s :: FulfillmentStartResponseSpecification
s@FulfillmentStartResponseSpecification' {} Natural
a -> FulfillmentStartResponseSpecification
s {$sel:delayInSeconds:FulfillmentStartResponseSpecification' :: Natural
delayInSeconds = Natural
a} :: FulfillmentStartResponseSpecification)

-- | One to 5 message groups that contain start messages. Amazon Lex chooses
-- one of the messages to play to the user.
fulfillmentStartResponseSpecification_messageGroups :: Lens.Lens' FulfillmentStartResponseSpecification (Prelude.NonEmpty MessageGroup)
fulfillmentStartResponseSpecification_messageGroups :: Lens' FulfillmentStartResponseSpecification (NonEmpty MessageGroup)
fulfillmentStartResponseSpecification_messageGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentStartResponseSpecification' {NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
$sel:messageGroups:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> NonEmpty MessageGroup
messageGroups} -> NonEmpty MessageGroup
messageGroups) (\s :: FulfillmentStartResponseSpecification
s@FulfillmentStartResponseSpecification' {} NonEmpty MessageGroup
a -> FulfillmentStartResponseSpecification
s {$sel:messageGroups:FulfillmentStartResponseSpecification' :: NonEmpty MessageGroup
messageGroups = NonEmpty MessageGroup
a} :: FulfillmentStartResponseSpecification) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    FulfillmentStartResponseSpecification
  where
  parseJSON :: Value -> Parser FulfillmentStartResponseSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FulfillmentStartResponseSpecification"
      ( \Object
x ->
          Maybe Bool
-> Natural
-> NonEmpty MessageGroup
-> FulfillmentStartResponseSpecification
FulfillmentStartResponseSpecification'
            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
"allowInterrupt")
            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
"delayInSeconds")
            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
"messageGroups")
      )

instance
  Prelude.Hashable
    FulfillmentStartResponseSpecification
  where
  hashWithSalt :: Int -> FulfillmentStartResponseSpecification -> Int
hashWithSalt
    Int
_salt
    FulfillmentStartResponseSpecification' {Natural
Maybe Bool
NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
delayInSeconds :: Natural
allowInterrupt :: Maybe Bool
$sel:messageGroups:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> NonEmpty MessageGroup
$sel:delayInSeconds:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Natural
$sel:allowInterrupt:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Maybe Bool
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowInterrupt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
delayInSeconds
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty MessageGroup
messageGroups

instance
  Prelude.NFData
    FulfillmentStartResponseSpecification
  where
  rnf :: FulfillmentStartResponseSpecification -> ()
rnf FulfillmentStartResponseSpecification' {Natural
Maybe Bool
NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
delayInSeconds :: Natural
allowInterrupt :: Maybe Bool
$sel:messageGroups:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> NonEmpty MessageGroup
$sel:delayInSeconds:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Natural
$sel:allowInterrupt:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowInterrupt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
delayInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty MessageGroup
messageGroups

instance
  Data.ToJSON
    FulfillmentStartResponseSpecification
  where
  toJSON :: FulfillmentStartResponseSpecification -> Value
toJSON FulfillmentStartResponseSpecification' {Natural
Maybe Bool
NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
delayInSeconds :: Natural
allowInterrupt :: Maybe Bool
$sel:messageGroups:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> NonEmpty MessageGroup
$sel:delayInSeconds:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Natural
$sel:allowInterrupt:FulfillmentStartResponseSpecification' :: FulfillmentStartResponseSpecification -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"allowInterrupt" 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
allowInterrupt,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"delayInSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
delayInSeconds),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"messageGroups" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty MessageGroup
messageGroups)
          ]
      )