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