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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Defines an ASCII text message to send to the user.
--
-- /See:/ 'newPlainTextMessage' smart constructor.
data PlainTextMessage = PlainTextMessage'
  { -- | The message to send to the user.
    PlainTextMessage -> Text
value :: Prelude.Text
  }
  deriving (PlainTextMessage -> PlainTextMessage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlainTextMessage -> PlainTextMessage -> Bool
$c/= :: PlainTextMessage -> PlainTextMessage -> Bool
== :: PlainTextMessage -> PlainTextMessage -> Bool
$c== :: PlainTextMessage -> PlainTextMessage -> Bool
Prelude.Eq, ReadPrec [PlainTextMessage]
ReadPrec PlainTextMessage
Int -> ReadS PlainTextMessage
ReadS [PlainTextMessage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlainTextMessage]
$creadListPrec :: ReadPrec [PlainTextMessage]
readPrec :: ReadPrec PlainTextMessage
$creadPrec :: ReadPrec PlainTextMessage
readList :: ReadS [PlainTextMessage]
$creadList :: ReadS [PlainTextMessage]
readsPrec :: Int -> ReadS PlainTextMessage
$creadsPrec :: Int -> ReadS PlainTextMessage
Prelude.Read, Int -> PlainTextMessage -> ShowS
[PlainTextMessage] -> ShowS
PlainTextMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlainTextMessage] -> ShowS
$cshowList :: [PlainTextMessage] -> ShowS
show :: PlainTextMessage -> String
$cshow :: PlainTextMessage -> String
showsPrec :: Int -> PlainTextMessage -> ShowS
$cshowsPrec :: Int -> PlainTextMessage -> ShowS
Prelude.Show, forall x. Rep PlainTextMessage x -> PlainTextMessage
forall x. PlainTextMessage -> Rep PlainTextMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlainTextMessage x -> PlainTextMessage
$cfrom :: forall x. PlainTextMessage -> Rep PlainTextMessage x
Prelude.Generic)

-- |
-- Create a value of 'PlainTextMessage' 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:
--
-- 'value', 'plainTextMessage_value' - The message to send to the user.
newPlainTextMessage ::
  -- | 'value'
  Prelude.Text ->
  PlainTextMessage
newPlainTextMessage :: Text -> PlainTextMessage
newPlainTextMessage Text
pValue_ =
  PlainTextMessage' {$sel:value:PlainTextMessage' :: Text
value = Text
pValue_}

-- | The message to send to the user.
plainTextMessage_value :: Lens.Lens' PlainTextMessage Prelude.Text
plainTextMessage_value :: Lens' PlainTextMessage Text
plainTextMessage_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlainTextMessage' {Text
value :: Text
$sel:value:PlainTextMessage' :: PlainTextMessage -> Text
value} -> Text
value) (\s :: PlainTextMessage
s@PlainTextMessage' {} Text
a -> PlainTextMessage
s {$sel:value:PlainTextMessage' :: Text
value = Text
a} :: PlainTextMessage)

instance Data.FromJSON PlainTextMessage where
  parseJSON :: Value -> Parser PlainTextMessage
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PlainTextMessage"
      ( \Object
x ->
          Text -> PlainTextMessage
PlainTextMessage' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"value")
      )

instance Prelude.Hashable PlainTextMessage where
  hashWithSalt :: Int -> PlainTextMessage -> Int
hashWithSalt Int
_salt PlainTextMessage' {Text
value :: Text
$sel:value:PlainTextMessage' :: PlainTextMessage -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData PlainTextMessage where
  rnf :: PlainTextMessage -> ()
rnf PlainTextMessage' {Text
value :: Text
$sel:value:PlainTextMessage' :: PlainTextMessage -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON PlainTextMessage where
  toJSON :: PlainTextMessage -> Value
toJSON PlainTextMessage' {Text
value :: Text
$sel:value:PlainTextMessage' :: PlainTextMessage -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)]
      )