module TD.Data.InputBusinessChatLink
( InputBusinessChatLink(..)
, defaultInputBusinessChatLink
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.FormattedText as FormattedText
import qualified Data.Text as T
data InputBusinessChatLink
= InputBusinessChatLink
{ InputBusinessChatLink -> Maybe FormattedText
text :: Maybe FormattedText.FormattedText
, InputBusinessChatLink -> Maybe Text
title :: Maybe T.Text
}
deriving (InputBusinessChatLink -> InputBusinessChatLink -> Bool
(InputBusinessChatLink -> InputBusinessChatLink -> Bool)
-> (InputBusinessChatLink -> InputBusinessChatLink -> Bool)
-> Eq InputBusinessChatLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InputBusinessChatLink -> InputBusinessChatLink -> Bool
== :: InputBusinessChatLink -> InputBusinessChatLink -> Bool
$c/= :: InputBusinessChatLink -> InputBusinessChatLink -> Bool
/= :: InputBusinessChatLink -> InputBusinessChatLink -> Bool
Eq, Int -> InputBusinessChatLink -> ShowS
[InputBusinessChatLink] -> ShowS
InputBusinessChatLink -> String
(Int -> InputBusinessChatLink -> ShowS)
-> (InputBusinessChatLink -> String)
-> ([InputBusinessChatLink] -> ShowS)
-> Show InputBusinessChatLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InputBusinessChatLink -> ShowS
showsPrec :: Int -> InputBusinessChatLink -> ShowS
$cshow :: InputBusinessChatLink -> String
show :: InputBusinessChatLink -> String
$cshowList :: [InputBusinessChatLink] -> ShowS
showList :: [InputBusinessChatLink] -> ShowS
Show)
instance I.ShortShow InputBusinessChatLink where
shortShow :: InputBusinessChatLink -> String
shortShow InputBusinessChatLink
{ text :: InputBusinessChatLink -> Maybe FormattedText
text = Maybe FormattedText
text_
, title :: InputBusinessChatLink -> Maybe Text
title = Maybe Text
title_
}
= String
"InputBusinessChatLink"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"text" String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
text_
, String
"title" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
]
instance AT.FromJSON InputBusinessChatLink where
parseJSON :: Value -> Parser InputBusinessChatLink
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"inputBusinessChatLink" -> Value -> Parser InputBusinessChatLink
parseInputBusinessChatLink Value
v
String
_ -> Parser InputBusinessChatLink
forall a. Monoid a => a
mempty
where
parseInputBusinessChatLink :: A.Value -> AT.Parser InputBusinessChatLink
parseInputBusinessChatLink :: Value -> Parser InputBusinessChatLink
parseInputBusinessChatLink = String
-> (Object -> Parser InputBusinessChatLink)
-> Value
-> Parser InputBusinessChatLink
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"InputBusinessChatLink" ((Object -> Parser InputBusinessChatLink)
-> Value -> Parser InputBusinessChatLink)
-> (Object -> Parser InputBusinessChatLink)
-> Value
-> Parser InputBusinessChatLink
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe FormattedText
text_ <- Object
o Object -> Key -> Parser (Maybe FormattedText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"text"
Maybe Text
title_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"title"
InputBusinessChatLink -> Parser InputBusinessChatLink
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InputBusinessChatLink -> Parser InputBusinessChatLink)
-> InputBusinessChatLink -> Parser InputBusinessChatLink
forall a b. (a -> b) -> a -> b
$ InputBusinessChatLink
{ text :: Maybe FormattedText
text = Maybe FormattedText
text_
, title :: Maybe Text
title = Maybe Text
title_
}
parseJSON Value
_ = Parser InputBusinessChatLink
forall a. Monoid a => a
mempty
instance AT.ToJSON InputBusinessChatLink where
toJSON :: InputBusinessChatLink -> Value
toJSON InputBusinessChatLink
{ text :: InputBusinessChatLink -> Maybe FormattedText
text = Maybe FormattedText
text_
, title :: InputBusinessChatLink -> Maybe Text
title = Maybe Text
title_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"inputBusinessChatLink"
, Key
"text" Key -> Maybe FormattedText -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe FormattedText
text_
, Key
"title" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
title_
]
defaultInputBusinessChatLink :: InputBusinessChatLink
defaultInputBusinessChatLink :: InputBusinessChatLink
defaultInputBusinessChatLink =
InputBusinessChatLink
{ text :: Maybe FormattedText
text = Maybe FormattedText
forall a. Maybe a
Nothing
, title :: Maybe Text
title = Maybe Text
forall a. Maybe a
Nothing
}