module TD.Data.BusinessChatLinks
(BusinessChatLinks(..)) 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.BusinessChatLink as BusinessChatLink
data BusinessChatLinks
= BusinessChatLinks
{ BusinessChatLinks -> Maybe [BusinessChatLink]
links :: Maybe [BusinessChatLink.BusinessChatLink]
}
deriving (BusinessChatLinks -> BusinessChatLinks -> Bool
(BusinessChatLinks -> BusinessChatLinks -> Bool)
-> (BusinessChatLinks -> BusinessChatLinks -> Bool)
-> Eq BusinessChatLinks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessChatLinks -> BusinessChatLinks -> Bool
== :: BusinessChatLinks -> BusinessChatLinks -> Bool
$c/= :: BusinessChatLinks -> BusinessChatLinks -> Bool
/= :: BusinessChatLinks -> BusinessChatLinks -> Bool
Eq, Int -> BusinessChatLinks -> ShowS
[BusinessChatLinks] -> ShowS
BusinessChatLinks -> String
(Int -> BusinessChatLinks -> ShowS)
-> (BusinessChatLinks -> String)
-> ([BusinessChatLinks] -> ShowS)
-> Show BusinessChatLinks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessChatLinks -> ShowS
showsPrec :: Int -> BusinessChatLinks -> ShowS
$cshow :: BusinessChatLinks -> String
show :: BusinessChatLinks -> String
$cshowList :: [BusinessChatLinks] -> ShowS
showList :: [BusinessChatLinks] -> ShowS
Show)
instance I.ShortShow BusinessChatLinks where
shortShow :: BusinessChatLinks -> String
shortShow BusinessChatLinks
{ links :: BusinessChatLinks -> Maybe [BusinessChatLink]
links = Maybe [BusinessChatLink]
links_
}
= String
"BusinessChatLinks"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"links" String -> Maybe [BusinessChatLink] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [BusinessChatLink]
links_
]
instance AT.FromJSON BusinessChatLinks where
parseJSON :: Value -> Parser BusinessChatLinks
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
"businessChatLinks" -> Value -> Parser BusinessChatLinks
parseBusinessChatLinks Value
v
String
_ -> Parser BusinessChatLinks
forall a. Monoid a => a
mempty
where
parseBusinessChatLinks :: A.Value -> AT.Parser BusinessChatLinks
parseBusinessChatLinks :: Value -> Parser BusinessChatLinks
parseBusinessChatLinks = String
-> (Object -> Parser BusinessChatLinks)
-> Value
-> Parser BusinessChatLinks
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BusinessChatLinks" ((Object -> Parser BusinessChatLinks)
-> Value -> Parser BusinessChatLinks)
-> (Object -> Parser BusinessChatLinks)
-> Value
-> Parser BusinessChatLinks
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [BusinessChatLink]
links_ <- Object
o Object -> Key -> Parser (Maybe [BusinessChatLink])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"links"
BusinessChatLinks -> Parser BusinessChatLinks
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BusinessChatLinks -> Parser BusinessChatLinks)
-> BusinessChatLinks -> Parser BusinessChatLinks
forall a b. (a -> b) -> a -> b
$ BusinessChatLinks
{ links :: Maybe [BusinessChatLink]
links = Maybe [BusinessChatLink]
links_
}
parseJSON Value
_ = Parser BusinessChatLinks
forall a. Monoid a => a
mempty