{-# 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-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.GenericAttachment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 list of options to show to the user.
    GenericAttachment -> Maybe [Button]
buttons :: Prelude.Maybe [Button],
    -- | The subtitle shown below the title.
    GenericAttachment -> Maybe Text
subTitle :: Prelude.Maybe Prelude.Text,
    -- | The URL of an image that is displayed to the user.
    GenericAttachment -> Maybe Text
imageUrl :: Prelude.Maybe Prelude.Text,
    -- | The URL of an attachment to the response card.
    GenericAttachment -> Maybe Text
attachmentLinkUrl :: Prelude.Maybe Prelude.Text,
    -- | The title of the option.
    GenericAttachment -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (GenericAttachment -> GenericAttachment -> Bool
(GenericAttachment -> GenericAttachment -> Bool)
-> (GenericAttachment -> GenericAttachment -> Bool)
-> Eq GenericAttachment
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]
(Int -> ReadS GenericAttachment)
-> ReadS [GenericAttachment]
-> ReadPrec GenericAttachment
-> ReadPrec [GenericAttachment]
-> Read 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
(Int -> GenericAttachment -> ShowS)
-> (GenericAttachment -> String)
-> ([GenericAttachment] -> ShowS)
-> Show GenericAttachment
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. GenericAttachment -> Rep GenericAttachment x)
-> (forall x. Rep GenericAttachment x -> GenericAttachment)
-> Generic GenericAttachment
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:
--
-- 'buttons', 'genericAttachment_buttons' - The list of options to show to the user.
--
-- 'subTitle', 'genericAttachment_subTitle' - The subtitle shown below the title.
--
-- 'imageUrl', 'genericAttachment_imageUrl' - The URL of an image that is displayed to the user.
--
-- 'attachmentLinkUrl', 'genericAttachment_attachmentLinkUrl' - The URL of an attachment to the response card.
--
-- 'title', 'genericAttachment_title' - The title of the option.
newGenericAttachment ::
  GenericAttachment
newGenericAttachment :: GenericAttachment
newGenericAttachment =
  GenericAttachment' :: Maybe [Button]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GenericAttachment
GenericAttachment'
    { $sel:buttons:GenericAttachment' :: Maybe [Button]
buttons = Maybe [Button]
forall a. Maybe a
Prelude.Nothing,
      $sel:subTitle:GenericAttachment' :: Maybe Text
subTitle = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageUrl:GenericAttachment' :: Maybe Text
imageUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attachmentLinkUrl:GenericAttachment' :: Maybe Text
attachmentLinkUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:title:GenericAttachment' :: Maybe Text
title = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of options to show to the user.
genericAttachment_buttons :: Lens.Lens' GenericAttachment (Prelude.Maybe [Button])
genericAttachment_buttons :: (Maybe [Button] -> f (Maybe [Button]))
-> GenericAttachment -> f GenericAttachment
genericAttachment_buttons = (GenericAttachment -> Maybe [Button])
-> (GenericAttachment -> Maybe [Button] -> GenericAttachment)
-> Lens
     GenericAttachment
     GenericAttachment
     (Maybe [Button])
     (Maybe [Button])
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) ((Maybe [Button] -> f (Maybe [Button]))
 -> GenericAttachment -> f GenericAttachment)
-> ((Maybe [Button] -> f (Maybe [Button]))
    -> Maybe [Button] -> f (Maybe [Button]))
-> (Maybe [Button] -> f (Maybe [Button]))
-> GenericAttachment
-> f GenericAttachment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Button] [Button] [Button] [Button]
-> Iso
     (Maybe [Button]) (Maybe [Button]) (Maybe [Button]) (Maybe [Button])
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 [Button] [Button] [Button] [Button]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The subtitle shown below the title.
genericAttachment_subTitle :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_subTitle :: (Maybe Text -> f (Maybe Text))
-> GenericAttachment -> f GenericAttachment
genericAttachment_subTitle = (GenericAttachment -> Maybe Text)
-> (GenericAttachment -> Maybe Text -> GenericAttachment)
-> Lens
     GenericAttachment GenericAttachment (Maybe Text) (Maybe Text)
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 URL of an image that is displayed to the user.
genericAttachment_imageUrl :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_imageUrl :: (Maybe Text -> f (Maybe Text))
-> GenericAttachment -> f GenericAttachment
genericAttachment_imageUrl = (GenericAttachment -> Maybe Text)
-> (GenericAttachment -> Maybe Text -> GenericAttachment)
-> Lens
     GenericAttachment GenericAttachment (Maybe Text) (Maybe Text)
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 URL of an attachment to the response card.
genericAttachment_attachmentLinkUrl :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_attachmentLinkUrl :: (Maybe Text -> f (Maybe Text))
-> GenericAttachment -> f GenericAttachment
genericAttachment_attachmentLinkUrl = (GenericAttachment -> Maybe Text)
-> (GenericAttachment -> Maybe Text -> GenericAttachment)
-> Lens
     GenericAttachment GenericAttachment (Maybe Text) (Maybe Text)
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 title of the option.
genericAttachment_title :: Lens.Lens' GenericAttachment (Prelude.Maybe Prelude.Text)
genericAttachment_title :: (Maybe Text -> f (Maybe Text))
-> GenericAttachment -> f GenericAttachment
genericAttachment_title = (GenericAttachment -> Maybe Text)
-> (GenericAttachment -> Maybe Text -> GenericAttachment)
-> Lens
     GenericAttachment GenericAttachment (Maybe Text) (Maybe Text)
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 Core.FromJSON GenericAttachment where
  parseJSON :: Value -> Parser GenericAttachment
parseJSON =
    String
-> (Object -> Parser GenericAttachment)
-> Value
-> Parser GenericAttachment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GenericAttachment"
      ( \Object
x ->
          Maybe [Button]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GenericAttachment
GenericAttachment'
            (Maybe [Button]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> GenericAttachment)
-> Parser (Maybe [Button])
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> GenericAttachment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Button]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"buttons" Parser (Maybe (Maybe [Button]))
-> Maybe [Button] -> Parser (Maybe [Button])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Button]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> GenericAttachment)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> GenericAttachment)
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
"subTitle")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> GenericAttachment)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> GenericAttachment)
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
"imageUrl")
            Parser (Maybe Text -> Maybe Text -> GenericAttachment)
-> Parser (Maybe Text) -> Parser (Maybe Text -> GenericAttachment)
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
"attachmentLinkUrl")
            Parser (Maybe Text -> GenericAttachment)
-> Parser (Maybe Text) -> Parser GenericAttachment
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
"title")
      )

instance Prelude.Hashable GenericAttachment

instance Prelude.NFData GenericAttachment