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