{-# 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.LexRuntime.Types.ResponseCard
-- 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.LexRuntime.Types.ResponseCard where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexRuntime.Types.ContentType
import Amazonka.LexRuntime.Types.GenericAttachment
import qualified Amazonka.Prelude as Prelude

-- | If you configure a response card when creating your bots, Amazon Lex
-- substitutes the session attributes and slot values that are available,
-- and then returns it. The response card can also come from a Lambda
-- function ( @dialogCodeHook@ and @fulfillmentActivity@ on an intent).
--
-- /See:/ 'newResponseCard' smart constructor.
data ResponseCard = ResponseCard'
  { -- | The content type of the response.
    ResponseCard -> Maybe ContentType
contentType :: Prelude.Maybe ContentType,
    -- | An array of attachment objects representing options.
    ResponseCard -> Maybe [GenericAttachment]
genericAttachments :: Prelude.Maybe [GenericAttachment],
    -- | The version of the response card format.
    ResponseCard -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (ResponseCard -> ResponseCard -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseCard -> ResponseCard -> Bool
$c/= :: ResponseCard -> ResponseCard -> Bool
== :: ResponseCard -> ResponseCard -> Bool
$c== :: ResponseCard -> ResponseCard -> Bool
Prelude.Eq, ReadPrec [ResponseCard]
ReadPrec ResponseCard
Int -> ReadS ResponseCard
ReadS [ResponseCard]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseCard]
$creadListPrec :: ReadPrec [ResponseCard]
readPrec :: ReadPrec ResponseCard
$creadPrec :: ReadPrec ResponseCard
readList :: ReadS [ResponseCard]
$creadList :: ReadS [ResponseCard]
readsPrec :: Int -> ReadS ResponseCard
$creadsPrec :: Int -> ReadS ResponseCard
Prelude.Read, Int -> ResponseCard -> ShowS
[ResponseCard] -> ShowS
ResponseCard -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseCard] -> ShowS
$cshowList :: [ResponseCard] -> ShowS
show :: ResponseCard -> String
$cshow :: ResponseCard -> String
showsPrec :: Int -> ResponseCard -> ShowS
$cshowsPrec :: Int -> ResponseCard -> ShowS
Prelude.Show, forall x. Rep ResponseCard x -> ResponseCard
forall x. ResponseCard -> Rep ResponseCard x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResponseCard x -> ResponseCard
$cfrom :: forall x. ResponseCard -> Rep ResponseCard x
Prelude.Generic)

-- |
-- Create a value of 'ResponseCard' 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:
--
-- 'contentType', 'responseCard_contentType' - The content type of the response.
--
-- 'genericAttachments', 'responseCard_genericAttachments' - An array of attachment objects representing options.
--
-- 'version', 'responseCard_version' - The version of the response card format.
newResponseCard ::
  ResponseCard
newResponseCard :: ResponseCard
newResponseCard =
  ResponseCard'
    { $sel:contentType:ResponseCard' :: Maybe ContentType
contentType = forall a. Maybe a
Prelude.Nothing,
      $sel:genericAttachments:ResponseCard' :: Maybe [GenericAttachment]
genericAttachments = forall a. Maybe a
Prelude.Nothing,
      $sel:version:ResponseCard' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing
    }

-- | The content type of the response.
responseCard_contentType :: Lens.Lens' ResponseCard (Prelude.Maybe ContentType)
responseCard_contentType :: Lens' ResponseCard (Maybe ContentType)
responseCard_contentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseCard' {Maybe ContentType
contentType :: Maybe ContentType
$sel:contentType:ResponseCard' :: ResponseCard -> Maybe ContentType
contentType} -> Maybe ContentType
contentType) (\s :: ResponseCard
s@ResponseCard' {} Maybe ContentType
a -> ResponseCard
s {$sel:contentType:ResponseCard' :: Maybe ContentType
contentType = Maybe ContentType
a} :: ResponseCard)

-- | An array of attachment objects representing options.
responseCard_genericAttachments :: Lens.Lens' ResponseCard (Prelude.Maybe [GenericAttachment])
responseCard_genericAttachments :: Lens' ResponseCard (Maybe [GenericAttachment])
responseCard_genericAttachments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseCard' {Maybe [GenericAttachment]
genericAttachments :: Maybe [GenericAttachment]
$sel:genericAttachments:ResponseCard' :: ResponseCard -> Maybe [GenericAttachment]
genericAttachments} -> Maybe [GenericAttachment]
genericAttachments) (\s :: ResponseCard
s@ResponseCard' {} Maybe [GenericAttachment]
a -> ResponseCard
s {$sel:genericAttachments:ResponseCard' :: Maybe [GenericAttachment]
genericAttachments = Maybe [GenericAttachment]
a} :: ResponseCard) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The version of the response card format.
responseCard_version :: Lens.Lens' ResponseCard (Prelude.Maybe Prelude.Text)
responseCard_version :: Lens' ResponseCard (Maybe Text)
responseCard_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseCard' {Maybe Text
version :: Maybe Text
$sel:version:ResponseCard' :: ResponseCard -> Maybe Text
version} -> Maybe Text
version) (\s :: ResponseCard
s@ResponseCard' {} Maybe Text
a -> ResponseCard
s {$sel:version:ResponseCard' :: Maybe Text
version = Maybe Text
a} :: ResponseCard)

instance Data.FromJSON ResponseCard where
  parseJSON :: Value -> Parser ResponseCard
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResponseCard"
      ( \Object
x ->
          Maybe ContentType
-> Maybe [GenericAttachment] -> Maybe Text -> ResponseCard
ResponseCard'
            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
"contentType")
            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
"genericAttachments"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"version")
      )

instance Prelude.Hashable ResponseCard where
  hashWithSalt :: Int -> ResponseCard -> Int
hashWithSalt Int
_salt ResponseCard' {Maybe [GenericAttachment]
Maybe Text
Maybe ContentType
version :: Maybe Text
genericAttachments :: Maybe [GenericAttachment]
contentType :: Maybe ContentType
$sel:version:ResponseCard' :: ResponseCard -> Maybe Text
$sel:genericAttachments:ResponseCard' :: ResponseCard -> Maybe [GenericAttachment]
$sel:contentType:ResponseCard' :: ResponseCard -> Maybe ContentType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContentType
contentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GenericAttachment]
genericAttachments
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version

instance Prelude.NFData ResponseCard where
  rnf :: ResponseCard -> ()
rnf ResponseCard' {Maybe [GenericAttachment]
Maybe Text
Maybe ContentType
version :: Maybe Text
genericAttachments :: Maybe [GenericAttachment]
contentType :: Maybe ContentType
$sel:version:ResponseCard' :: ResponseCard -> Maybe Text
$sel:genericAttachments:ResponseCard' :: ResponseCard -> Maybe [GenericAttachment]
$sel:contentType:ResponseCard' :: ResponseCard -> Maybe ContentType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ContentType
contentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [GenericAttachment]
genericAttachments
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version