{-# 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.FulfillmentUpdateResponseSpecification
-- 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.FulfillmentUpdateResponseSpecification 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 periodically to the user
-- while a fulfillment Lambda function is running.
--
-- /See:/ 'newFulfillmentUpdateResponseSpecification' smart constructor.
data FulfillmentUpdateResponseSpecification = FulfillmentUpdateResponseSpecification'
  { -- | Determines whether the user can interrupt an update message while it is
    -- playing.
    FulfillmentUpdateResponseSpecification -> Maybe Bool
allowInterrupt :: Prelude.Maybe Prelude.Bool,
    -- | The frequency that a message is sent to the user. When the period ends,
    -- Amazon Lex chooses a message from the message groups and plays it to the
    -- user. If the fulfillment Lambda returns before the first period ends, an
    -- update message is not played to the user.
    FulfillmentUpdateResponseSpecification -> Natural
frequencyInSeconds :: Prelude.Natural,
    -- | One to 5 message groups that contain update messages. Amazon Lex chooses
    -- one of the messages to play to the user.
    FulfillmentUpdateResponseSpecification -> NonEmpty MessageGroup
messageGroups :: Prelude.NonEmpty MessageGroup
  }
  deriving (FulfillmentUpdateResponseSpecification
-> FulfillmentUpdateResponseSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FulfillmentUpdateResponseSpecification
-> FulfillmentUpdateResponseSpecification -> Bool
$c/= :: FulfillmentUpdateResponseSpecification
-> FulfillmentUpdateResponseSpecification -> Bool
== :: FulfillmentUpdateResponseSpecification
-> FulfillmentUpdateResponseSpecification -> Bool
$c== :: FulfillmentUpdateResponseSpecification
-> FulfillmentUpdateResponseSpecification -> Bool
Prelude.Eq, ReadPrec [FulfillmentUpdateResponseSpecification]
ReadPrec FulfillmentUpdateResponseSpecification
Int -> ReadS FulfillmentUpdateResponseSpecification
ReadS [FulfillmentUpdateResponseSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FulfillmentUpdateResponseSpecification]
$creadListPrec :: ReadPrec [FulfillmentUpdateResponseSpecification]
readPrec :: ReadPrec FulfillmentUpdateResponseSpecification
$creadPrec :: ReadPrec FulfillmentUpdateResponseSpecification
readList :: ReadS [FulfillmentUpdateResponseSpecification]
$creadList :: ReadS [FulfillmentUpdateResponseSpecification]
readsPrec :: Int -> ReadS FulfillmentUpdateResponseSpecification
$creadsPrec :: Int -> ReadS FulfillmentUpdateResponseSpecification
Prelude.Read, Int -> FulfillmentUpdateResponseSpecification -> ShowS
[FulfillmentUpdateResponseSpecification] -> ShowS
FulfillmentUpdateResponseSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FulfillmentUpdateResponseSpecification] -> ShowS
$cshowList :: [FulfillmentUpdateResponseSpecification] -> ShowS
show :: FulfillmentUpdateResponseSpecification -> String
$cshow :: FulfillmentUpdateResponseSpecification -> String
showsPrec :: Int -> FulfillmentUpdateResponseSpecification -> ShowS
$cshowsPrec :: Int -> FulfillmentUpdateResponseSpecification -> ShowS
Prelude.Show, forall x.
Rep FulfillmentUpdateResponseSpecification x
-> FulfillmentUpdateResponseSpecification
forall x.
FulfillmentUpdateResponseSpecification
-> Rep FulfillmentUpdateResponseSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FulfillmentUpdateResponseSpecification x
-> FulfillmentUpdateResponseSpecification
$cfrom :: forall x.
FulfillmentUpdateResponseSpecification
-> Rep FulfillmentUpdateResponseSpecification x
Prelude.Generic)

-- |
-- Create a value of 'FulfillmentUpdateResponseSpecification' 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', 'fulfillmentUpdateResponseSpecification_allowInterrupt' - Determines whether the user can interrupt an update message while it is
-- playing.
--
-- 'frequencyInSeconds', 'fulfillmentUpdateResponseSpecification_frequencyInSeconds' - The frequency that a message is sent to the user. When the period ends,
-- Amazon Lex chooses a message from the message groups and plays it to the
-- user. If the fulfillment Lambda returns before the first period ends, an
-- update message is not played to the user.
--
-- 'messageGroups', 'fulfillmentUpdateResponseSpecification_messageGroups' - One to 5 message groups that contain update messages. Amazon Lex chooses
-- one of the messages to play to the user.
newFulfillmentUpdateResponseSpecification ::
  -- | 'frequencyInSeconds'
  Prelude.Natural ->
  -- | 'messageGroups'
  Prelude.NonEmpty MessageGroup ->
  FulfillmentUpdateResponseSpecification
newFulfillmentUpdateResponseSpecification :: Natural
-> NonEmpty MessageGroup -> FulfillmentUpdateResponseSpecification
newFulfillmentUpdateResponseSpecification
  Natural
pFrequencyInSeconds_
  NonEmpty MessageGroup
pMessageGroups_ =
    FulfillmentUpdateResponseSpecification'
      { $sel:allowInterrupt:FulfillmentUpdateResponseSpecification' :: Maybe Bool
allowInterrupt =
          forall a. Maybe a
Prelude.Nothing,
        $sel:frequencyInSeconds:FulfillmentUpdateResponseSpecification' :: Natural
frequencyInSeconds =
          Natural
pFrequencyInSeconds_,
        $sel:messageGroups:FulfillmentUpdateResponseSpecification' :: 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 an update message while it is
-- playing.
fulfillmentUpdateResponseSpecification_allowInterrupt :: Lens.Lens' FulfillmentUpdateResponseSpecification (Prelude.Maybe Prelude.Bool)
fulfillmentUpdateResponseSpecification_allowInterrupt :: Lens' FulfillmentUpdateResponseSpecification (Maybe Bool)
fulfillmentUpdateResponseSpecification_allowInterrupt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdateResponseSpecification' {Maybe Bool
allowInterrupt :: Maybe Bool
$sel:allowInterrupt:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> Maybe Bool
allowInterrupt} -> Maybe Bool
allowInterrupt) (\s :: FulfillmentUpdateResponseSpecification
s@FulfillmentUpdateResponseSpecification' {} Maybe Bool
a -> FulfillmentUpdateResponseSpecification
s {$sel:allowInterrupt:FulfillmentUpdateResponseSpecification' :: Maybe Bool
allowInterrupt = Maybe Bool
a} :: FulfillmentUpdateResponseSpecification)

-- | The frequency that a message is sent to the user. When the period ends,
-- Amazon Lex chooses a message from the message groups and plays it to the
-- user. If the fulfillment Lambda returns before the first period ends, an
-- update message is not played to the user.
fulfillmentUpdateResponseSpecification_frequencyInSeconds :: Lens.Lens' FulfillmentUpdateResponseSpecification Prelude.Natural
fulfillmentUpdateResponseSpecification_frequencyInSeconds :: Lens' FulfillmentUpdateResponseSpecification Natural
fulfillmentUpdateResponseSpecification_frequencyInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdateResponseSpecification' {Natural
frequencyInSeconds :: Natural
$sel:frequencyInSeconds:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> Natural
frequencyInSeconds} -> Natural
frequencyInSeconds) (\s :: FulfillmentUpdateResponseSpecification
s@FulfillmentUpdateResponseSpecification' {} Natural
a -> FulfillmentUpdateResponseSpecification
s {$sel:frequencyInSeconds:FulfillmentUpdateResponseSpecification' :: Natural
frequencyInSeconds = Natural
a} :: FulfillmentUpdateResponseSpecification)

-- | One to 5 message groups that contain update messages. Amazon Lex chooses
-- one of the messages to play to the user.
fulfillmentUpdateResponseSpecification_messageGroups :: Lens.Lens' FulfillmentUpdateResponseSpecification (Prelude.NonEmpty MessageGroup)
fulfillmentUpdateResponseSpecification_messageGroups :: Lens'
  FulfillmentUpdateResponseSpecification (NonEmpty MessageGroup)
fulfillmentUpdateResponseSpecification_messageGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdateResponseSpecification' {NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
$sel:messageGroups:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> NonEmpty MessageGroup
messageGroups} -> NonEmpty MessageGroup
messageGroups) (\s :: FulfillmentUpdateResponseSpecification
s@FulfillmentUpdateResponseSpecification' {} NonEmpty MessageGroup
a -> FulfillmentUpdateResponseSpecification
s {$sel:messageGroups:FulfillmentUpdateResponseSpecification' :: NonEmpty MessageGroup
messageGroups = NonEmpty MessageGroup
a} :: FulfillmentUpdateResponseSpecification) 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
    FulfillmentUpdateResponseSpecification
  where
  parseJSON :: Value -> Parser FulfillmentUpdateResponseSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FulfillmentUpdateResponseSpecification"
      ( \Object
x ->
          Maybe Bool
-> Natural
-> NonEmpty MessageGroup
-> FulfillmentUpdateResponseSpecification
FulfillmentUpdateResponseSpecification'
            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
"frequencyInSeconds")
            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
    FulfillmentUpdateResponseSpecification
  where
  hashWithSalt :: Int -> FulfillmentUpdateResponseSpecification -> Int
hashWithSalt
    Int
_salt
    FulfillmentUpdateResponseSpecification' {Natural
Maybe Bool
NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
frequencyInSeconds :: Natural
allowInterrupt :: Maybe Bool
$sel:messageGroups:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> NonEmpty MessageGroup
$sel:frequencyInSeconds:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> Natural
$sel:allowInterrupt:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> 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
frequencyInSeconds
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty MessageGroup
messageGroups

instance
  Prelude.NFData
    FulfillmentUpdateResponseSpecification
  where
  rnf :: FulfillmentUpdateResponseSpecification -> ()
rnf FulfillmentUpdateResponseSpecification' {Natural
Maybe Bool
NonEmpty MessageGroup
messageGroups :: NonEmpty MessageGroup
frequencyInSeconds :: Natural
allowInterrupt :: Maybe Bool
$sel:messageGroups:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> NonEmpty MessageGroup
$sel:frequencyInSeconds:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> Natural
$sel:allowInterrupt:FulfillmentUpdateResponseSpecification' :: FulfillmentUpdateResponseSpecification -> 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
frequencyInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty MessageGroup
messageGroups

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