{-# 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 #-}
module Amazonka.LexModels.Types.Message where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LexModels.Types.ContentType
import qualified Amazonka.Prelude as Prelude
data Message = Message'
{
Message -> Maybe Natural
groupNumber :: Prelude.Maybe Prelude.Natural,
Message -> ContentType
contentType :: ContentType,
Message -> Text
content :: Prelude.Text
}
deriving (Message -> Message -> Bool
(Message -> Message -> Bool)
-> (Message -> Message -> Bool) -> Eq Message
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c== :: Message -> Message -> Bool
Prelude.Eq, ReadPrec [Message]
ReadPrec Message
Int -> ReadS Message
ReadS [Message]
(Int -> ReadS Message)
-> ReadS [Message]
-> ReadPrec Message
-> ReadPrec [Message]
-> Read Message
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Message]
$creadListPrec :: ReadPrec [Message]
readPrec :: ReadPrec Message
$creadPrec :: ReadPrec Message
readList :: ReadS [Message]
$creadList :: ReadS [Message]
readsPrec :: Int -> ReadS Message
$creadsPrec :: Int -> ReadS Message
Prelude.Read, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
(Int -> Message -> ShowS)
-> (Message -> String) -> ([Message] -> ShowS) -> Show Message
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> String
$cshow :: Message -> String
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Prelude.Show, (forall x. Message -> Rep Message x)
-> (forall x. Rep Message x -> Message) -> Generic Message
forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Message x -> Message
$cfrom :: forall x. Message -> Rep Message x
Prelude.Generic)
newMessage ::
ContentType ->
Prelude.Text ->
Message
newMessage :: ContentType -> Text -> Message
newMessage ContentType
pContentType_ Text
pContent_ =
Message' :: Maybe Natural -> ContentType -> Text -> Message
Message'
{ $sel:groupNumber:Message' :: Maybe Natural
groupNumber = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:contentType:Message' :: ContentType
contentType = ContentType
pContentType_,
$sel:content:Message' :: Text
content = Text
pContent_
}
message_groupNumber :: Lens.Lens' Message (Prelude.Maybe Prelude.Natural)
message_groupNumber :: (Maybe Natural -> f (Maybe Natural)) -> Message -> f Message
message_groupNumber = (Message -> Maybe Natural)
-> (Message -> Maybe Natural -> Message)
-> Lens Message Message (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Natural
groupNumber :: Maybe Natural
$sel:groupNumber:Message' :: Message -> Maybe Natural
groupNumber} -> Maybe Natural
groupNumber) (\s :: Message
s@Message' {} Maybe Natural
a -> Message
s {$sel:groupNumber:Message' :: Maybe Natural
groupNumber = Maybe Natural
a} :: Message)
message_contentType :: Lens.Lens' Message ContentType
message_contentType :: (ContentType -> f ContentType) -> Message -> f Message
message_contentType = (Message -> ContentType)
-> (Message -> ContentType -> Message)
-> Lens Message Message ContentType ContentType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {ContentType
contentType :: ContentType
$sel:contentType:Message' :: Message -> ContentType
contentType} -> ContentType
contentType) (\s :: Message
s@Message' {} ContentType
a -> Message
s {$sel:contentType:Message' :: ContentType
contentType = ContentType
a} :: Message)
message_content :: Lens.Lens' Message Prelude.Text
message_content :: (Text -> f Text) -> Message -> f Message
message_content = (Message -> Text)
-> (Message -> Text -> Message) -> Lens Message Message Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Text
content :: Text
$sel:content:Message' :: Message -> Text
content} -> Text
content) (\s :: Message
s@Message' {} Text
a -> Message
s {$sel:content:Message' :: Text
content = Text
a} :: Message)
instance Core.FromJSON Message where
parseJSON :: Value -> Parser Message
parseJSON =
String -> (Object -> Parser Message) -> Value -> Parser Message
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Message"
( \Object
x ->
Maybe Natural -> ContentType -> Text -> Message
Message'
(Maybe Natural -> ContentType -> Text -> Message)
-> Parser (Maybe Natural)
-> Parser (ContentType -> Text -> Message)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupNumber")
Parser (ContentType -> Text -> Message)
-> Parser ContentType -> Parser (Text -> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ContentType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"contentType")
Parser (Text -> Message) -> Parser Text -> Parser Message
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"content")
)
instance Prelude.Hashable Message
instance Prelude.NFData Message
instance Core.ToJSON Message where
toJSON :: Message -> Value
toJSON Message' {Maybe Natural
Text
ContentType
content :: Text
contentType :: ContentType
groupNumber :: Maybe Natural
$sel:content:Message' :: Message -> Text
$sel:contentType:Message' :: Message -> ContentType
$sel:groupNumber:Message' :: Message -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"groupNumber" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
groupNumber,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"contentType" Text -> ContentType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContentType
contentType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"content" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
content)
]
)