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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | The content type of the response.
    ResponseCard -> Maybe ContentType
contentType :: Prelude.Maybe ContentType
  }
  deriving (ResponseCard -> ResponseCard -> Bool
(ResponseCard -> ResponseCard -> Bool)
-> (ResponseCard -> ResponseCard -> Bool) -> Eq ResponseCard
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]
(Int -> ReadS ResponseCard)
-> ReadS [ResponseCard]
-> ReadPrec ResponseCard
-> ReadPrec [ResponseCard]
-> Read 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
(Int -> ResponseCard -> ShowS)
-> (ResponseCard -> String)
-> ([ResponseCard] -> ShowS)
-> Show ResponseCard
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. ResponseCard -> Rep ResponseCard x)
-> (forall x. Rep ResponseCard x -> ResponseCard)
-> Generic ResponseCard
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:
--
-- 'genericAttachments', 'responseCard_genericAttachments' - An array of attachment objects representing options.
--
-- 'version', 'responseCard_version' - The version of the response card format.
--
-- 'contentType', 'responseCard_contentType' - The content type of the response.
newResponseCard ::
  ResponseCard
newResponseCard :: ResponseCard
newResponseCard =
  ResponseCard' :: Maybe [GenericAttachment]
-> Maybe Text -> Maybe ContentType -> ResponseCard
ResponseCard'
    { $sel:genericAttachments:ResponseCard' :: Maybe [GenericAttachment]
genericAttachments = Maybe [GenericAttachment]
forall a. Maybe a
Prelude.Nothing,
      $sel:version:ResponseCard' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contentType:ResponseCard' :: Maybe ContentType
contentType = Maybe ContentType
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of attachment objects representing options.
responseCard_genericAttachments :: Lens.Lens' ResponseCard (Prelude.Maybe [GenericAttachment])
responseCard_genericAttachments :: (Maybe [GenericAttachment] -> f (Maybe [GenericAttachment]))
-> ResponseCard -> f ResponseCard
responseCard_genericAttachments = (ResponseCard -> Maybe [GenericAttachment])
-> (ResponseCard -> Maybe [GenericAttachment] -> ResponseCard)
-> Lens
     ResponseCard
     ResponseCard
     (Maybe [GenericAttachment])
     (Maybe [GenericAttachment])
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) ((Maybe [GenericAttachment] -> f (Maybe [GenericAttachment]))
 -> ResponseCard -> f ResponseCard)
-> ((Maybe [GenericAttachment] -> f (Maybe [GenericAttachment]))
    -> Maybe [GenericAttachment] -> f (Maybe [GenericAttachment]))
-> (Maybe [GenericAttachment] -> f (Maybe [GenericAttachment]))
-> ResponseCard
-> f ResponseCard
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GenericAttachment]
  [GenericAttachment]
  [GenericAttachment]
  [GenericAttachment]
-> Iso
     (Maybe [GenericAttachment])
     (Maybe [GenericAttachment])
     (Maybe [GenericAttachment])
     (Maybe [GenericAttachment])
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 AnIso
  [GenericAttachment]
  [GenericAttachment]
  [GenericAttachment]
  [GenericAttachment]
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 :: (Maybe Text -> f (Maybe Text)) -> ResponseCard -> f ResponseCard
responseCard_version = (ResponseCard -> Maybe Text)
-> (ResponseCard -> Maybe Text -> ResponseCard)
-> Lens ResponseCard ResponseCard (Maybe Text) (Maybe Text)
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)

-- | The content type of the response.
responseCard_contentType :: Lens.Lens' ResponseCard (Prelude.Maybe ContentType)
responseCard_contentType :: (Maybe ContentType -> f (Maybe ContentType))
-> ResponseCard -> f ResponseCard
responseCard_contentType = (ResponseCard -> Maybe ContentType)
-> (ResponseCard -> Maybe ContentType -> ResponseCard)
-> Lens
     ResponseCard ResponseCard (Maybe ContentType) (Maybe 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)

instance Core.FromJSON ResponseCard where
  parseJSON :: Value -> Parser ResponseCard
parseJSON =
    String
-> (Object -> Parser ResponseCard) -> Value -> Parser ResponseCard
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResponseCard"
      ( \Object
x ->
          Maybe [GenericAttachment]
-> Maybe Text -> Maybe ContentType -> ResponseCard
ResponseCard'
            (Maybe [GenericAttachment]
 -> Maybe Text -> Maybe ContentType -> ResponseCard)
-> Parser (Maybe [GenericAttachment])
-> Parser (Maybe Text -> Maybe ContentType -> ResponseCard)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [GenericAttachment]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"genericAttachments"
                            Parser (Maybe (Maybe [GenericAttachment]))
-> Maybe [GenericAttachment] -> Parser (Maybe [GenericAttachment])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GenericAttachment]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe ContentType -> ResponseCard)
-> Parser (Maybe Text)
-> Parser (Maybe ContentType -> ResponseCard)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"version")
            Parser (Maybe ContentType -> ResponseCard)
-> Parser (Maybe ContentType) -> Parser ResponseCard
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ContentType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"contentType")
      )

instance Prelude.Hashable ResponseCard

instance Prelude.NFData ResponseCard