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

-- | Represents an option rendered to the user when a prompt is shown. It
-- could be an image, a button, a link, or text.
--
-- /See:/ 'newGenericAttachment' smart constructor.
data GenericAttachment = GenericAttachment'
  { -- | The URL of an attachment to the response card.
    GenericAttachment -> Maybe Text
attachmentLinkUrl :: Prelude.Maybe Prelude.Text,
    -- | The list of options to show to the user.
    GenericAttachment -> Maybe [Button]
buttons :: Prelude.Maybe [Button],
    -- | The URL of an image that is displayed to the user.
    GenericAttachment -> Maybe Text
imageUrl :: Prelude.Maybe Prelude.Text,
    -- | The subtitle shown below the title.
    GenericAttachment -> Maybe Text
subTitle :: Prelude.Maybe Prelude.Text,
    -- | The title of the option.
    GenericAttachment -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (GenericAttachment -> GenericAttachment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenericAttachment -> GenericAttachment -> Bool
$c/= :: GenericAttachment -> GenericAttachment -> Bool
== :: GenericAttachment -> GenericAttachment -> Bool
$c== :: GenericAttachment -> GenericAttachment -> Bool
Prelude.Eq, ReadPrec [GenericAttachment]
ReadPrec GenericAttachment
Int -> ReadS GenericAttachment
ReadS [GenericAttachment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenericAttachment]
$creadListPrec :: ReadPrec [GenericAttachment]
readPrec :: ReadPrec GenericAttachment
$creadPrec :: ReadPrec GenericAttachment
readList :: ReadS [GenericAttachment]
$creadList :: ReadS [GenericAttachment]
readsPrec :: Int -> ReadS GenericAttachment
$creadsPrec :: Int -> ReadS GenericAttachment
Prelude.Read, Int -> GenericAttachment -> ShowS
[GenericAttachment] -> ShowS
GenericAttachment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenericAttachment] -> ShowS
$cshowList :: [GenericAttachment] -> ShowS
show :: GenericAttachment -> String
$cshow :: GenericAttachment -> String
showsPrec :: Int -> GenericAttachment -> ShowS
$cshowsPrec :: Int -> GenericAttachment -> ShowS
Prelude.Show, forall x. Rep GenericAttachment x -> GenericAttachment
forall x. GenericAttachment -> Rep GenericAttachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GenericAttachment x -> GenericAttachment
$cfrom :: forall x. GenericAttachment -> Rep GenericAttachment x
Prelude.Generic)

-- |
-- Create a value of 'GenericAttachment' 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:
--
-- 'attachmentLinkUrl', 'genericAttachment_attachmentLinkUrl' - The URL of an attachment to the response card.
--
-- 'buttons', 'genericAttachment_buttons' - The list of options to show to the user.
--
-- 'imageUrl', 'genericAttachment_imageUrl' - The URL of an image that is displayed to the user.
--
-- 'subTitle', 'genericAttachment_subTitle' - The subtitle shown below the title.
--
-- 'title', 'genericAttachment_title' - The title of the option.
newGenericAttachment ::
  GenericAttachment
newGenericAttachment :: GenericAttachment
newGenericAttachment =
  GenericAttachment'
    { $sel:attachmentLinkUrl:GenericAttachment' :: Maybe Text
attachmentLinkUrl =
        forall a. Maybe a
Prelude.Nothing,
      $sel:buttons:GenericAttachment' :: Maybe [Button]
buttons = forall a. Maybe a
Prelude.Nothing,
      $sel:imageUrl:GenericAttachment' :: Maybe Text
imageUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:subTitle:GenericAttachment' :: Maybe Text
subTitle = forall a. Maybe a
Prelude.Nothing,
      $sel:title:GenericAttachment' :: Maybe Text
title = forall a. Maybe a
Prelude.Nothing
    }

-- | The URL of an attachment to the response card.
genericAttachment_attachmentLinkUrl :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_attachmentLinkUrl :: Lens' GenericAttachment (Maybe Text)
genericAttachment_attachmentLinkUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenericAttachment' {Maybe Text
attachmentLinkUrl :: Maybe Text
$sel:attachmentLinkUrl:GenericAttachment' :: GenericAttachment -> Maybe Text
attachmentLinkUrl} -> Maybe Text
attachmentLinkUrl) (\s :: GenericAttachment
s@GenericAttachment' {} Maybe Text
a -> GenericAttachment
s {$sel:attachmentLinkUrl:GenericAttachment' :: Maybe Text
attachmentLinkUrl = Maybe Text
a} :: GenericAttachment)

-- | The list of options to show to the user.
genericAttachment_buttons :: Lens.Lens' GenericAttachment (Prelude.Maybe [Button])
genericAttachment_buttons :: Lens' GenericAttachment (Maybe [Button])
genericAttachment_buttons = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenericAttachment' {Maybe [Button]
buttons :: Maybe [Button]
$sel:buttons:GenericAttachment' :: GenericAttachment -> Maybe [Button]
buttons} -> Maybe [Button]
buttons) (\s :: GenericAttachment
s@GenericAttachment' {} Maybe [Button]
a -> GenericAttachment
s {$sel:buttons:GenericAttachment' :: Maybe [Button]
buttons = Maybe [Button]
a} :: GenericAttachment) 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 URL of an image that is displayed to the user.
genericAttachment_imageUrl :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_imageUrl :: Lens' GenericAttachment (Maybe Text)
genericAttachment_imageUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenericAttachment' {Maybe Text
imageUrl :: Maybe Text
$sel:imageUrl:GenericAttachment' :: GenericAttachment -> Maybe Text
imageUrl} -> Maybe Text
imageUrl) (\s :: GenericAttachment
s@GenericAttachment' {} Maybe Text
a -> GenericAttachment
s {$sel:imageUrl:GenericAttachment' :: Maybe Text
imageUrl = Maybe Text
a} :: GenericAttachment)

-- | The subtitle shown below the title.
genericAttachment_subTitle :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_subTitle :: Lens' GenericAttachment (Maybe Text)
genericAttachment_subTitle = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenericAttachment' {Maybe Text
subTitle :: Maybe Text
$sel:subTitle:GenericAttachment' :: GenericAttachment -> Maybe Text
subTitle} -> Maybe Text
subTitle) (\s :: GenericAttachment
s@GenericAttachment' {} Maybe Text
a -> GenericAttachment
s {$sel:subTitle:GenericAttachment' :: Maybe Text
subTitle = Maybe Text
a} :: GenericAttachment)

-- | The title of the option.
genericAttachment_title :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_title :: Lens' GenericAttachment (Maybe Text)
genericAttachment_title = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenericAttachment' {Maybe Text
title :: Maybe Text
$sel:title:GenericAttachment' :: GenericAttachment -> Maybe Text
title} -> Maybe Text
title) (\s :: GenericAttachment
s@GenericAttachment' {} Maybe Text
a -> GenericAttachment
s {$sel:title:GenericAttachment' :: Maybe Text
title = Maybe Text
a} :: GenericAttachment)

instance Data.FromJSON GenericAttachment where
  parseJSON :: Value -> Parser GenericAttachment
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GenericAttachment"
      ( \Object
x ->
          Maybe Text
-> Maybe [Button]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GenericAttachment
GenericAttachment'
            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
"attachmentLinkUrl")
            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
"buttons" 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
"imageUrl")
            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
"subTitle")
            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
"title")
      )

instance Prelude.Hashable GenericAttachment where
  hashWithSalt :: Int -> GenericAttachment -> Int
hashWithSalt Int
_salt GenericAttachment' {Maybe [Button]
Maybe Text
title :: Maybe Text
subTitle :: Maybe Text
imageUrl :: Maybe Text
buttons :: Maybe [Button]
attachmentLinkUrl :: Maybe Text
$sel:title:GenericAttachment' :: GenericAttachment -> Maybe Text
$sel:subTitle:GenericAttachment' :: GenericAttachment -> Maybe Text
$sel:imageUrl:GenericAttachment' :: GenericAttachment -> Maybe Text
$sel:buttons:GenericAttachment' :: GenericAttachment -> Maybe [Button]
$sel:attachmentLinkUrl:GenericAttachment' :: GenericAttachment -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attachmentLinkUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Button]
buttons
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
imageUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subTitle
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
title

instance Prelude.NFData GenericAttachment where
  rnf :: GenericAttachment -> ()
rnf GenericAttachment' {Maybe [Button]
Maybe Text
title :: Maybe Text
subTitle :: Maybe Text
imageUrl :: Maybe Text
buttons :: Maybe [Button]
attachmentLinkUrl :: Maybe Text
$sel:title:GenericAttachment' :: GenericAttachment -> Maybe Text
$sel:subTitle:GenericAttachment' :: GenericAttachment -> Maybe Text
$sel:imageUrl:GenericAttachment' :: GenericAttachment -> Maybe Text
$sel:buttons:GenericAttachment' :: GenericAttachment -> Maybe [Button]
$sel:attachmentLinkUrl:GenericAttachment' :: GenericAttachment -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attachmentLinkUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Button]
buttons
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
imageUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subTitle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
title