{-# 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.CustomPayload
-- 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.CustomPayload 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

-- | A custom response string that Amazon Lex sends to your application. You
-- define the content and structure the string.
--
-- /See:/ 'newCustomPayload' smart constructor.
data CustomPayload = CustomPayload'
  { -- | The string that is sent to your application.
    CustomPayload -> Text
value :: Prelude.Text
  }
  deriving (CustomPayload -> CustomPayload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomPayload -> CustomPayload -> Bool
$c/= :: CustomPayload -> CustomPayload -> Bool
== :: CustomPayload -> CustomPayload -> Bool
$c== :: CustomPayload -> CustomPayload -> Bool
Prelude.Eq, ReadPrec [CustomPayload]
ReadPrec CustomPayload
Int -> ReadS CustomPayload
ReadS [CustomPayload]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomPayload]
$creadListPrec :: ReadPrec [CustomPayload]
readPrec :: ReadPrec CustomPayload
$creadPrec :: ReadPrec CustomPayload
readList :: ReadS [CustomPayload]
$creadList :: ReadS [CustomPayload]
readsPrec :: Int -> ReadS CustomPayload
$creadsPrec :: Int -> ReadS CustomPayload
Prelude.Read, Int -> CustomPayload -> ShowS
[CustomPayload] -> ShowS
CustomPayload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomPayload] -> ShowS
$cshowList :: [CustomPayload] -> ShowS
show :: CustomPayload -> String
$cshow :: CustomPayload -> String
showsPrec :: Int -> CustomPayload -> ShowS
$cshowsPrec :: Int -> CustomPayload -> ShowS
Prelude.Show, forall x. Rep CustomPayload x -> CustomPayload
forall x. CustomPayload -> Rep CustomPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomPayload x -> CustomPayload
$cfrom :: forall x. CustomPayload -> Rep CustomPayload x
Prelude.Generic)

-- |
-- Create a value of 'CustomPayload' 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', 'customPayload_value' - The string that is sent to your application.
newCustomPayload ::
  -- | 'value'
  Prelude.Text ->
  CustomPayload
newCustomPayload :: Text -> CustomPayload
newCustomPayload Text
pValue_ =
  CustomPayload' {$sel:value:CustomPayload' :: Text
value = Text
pValue_}

-- | The string that is sent to your application.
customPayload_value :: Lens.Lens' CustomPayload Prelude.Text
customPayload_value :: Lens' CustomPayload Text
customPayload_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomPayload' {Text
value :: Text
$sel:value:CustomPayload' :: CustomPayload -> Text
value} -> Text
value) (\s :: CustomPayload
s@CustomPayload' {} Text
a -> CustomPayload
s {$sel:value:CustomPayload' :: Text
value = Text
a} :: CustomPayload)

instance Data.FromJSON CustomPayload where
  parseJSON :: Value -> Parser CustomPayload
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomPayload"
      ( \Object
x ->
          Text -> CustomPayload
CustomPayload' 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 CustomPayload where
  hashWithSalt :: Int -> CustomPayload -> Int
hashWithSalt Int
_salt CustomPayload' {Text
value :: Text
$sel:value:CustomPayload' :: CustomPayload -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

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

instance Data.ToJSON CustomPayload where
  toJSON :: CustomPayload -> Value
toJSON CustomPayload' {Text
value :: Text
$sel:value:CustomPayload' :: CustomPayload -> 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)]
      )