module TD.Query.GetStorageStatistics
  (GetStorageStatistics(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Returns storage usage statistics. Can be called before authorization. Returns 'TD.Data.StorageStatistics.StorageStatistics'
data GetStorageStatistics
  = GetStorageStatistics
    { GetStorageStatistics -> Maybe Int
chat_limit :: Maybe Int -- ^ The maximum number of chats with the largest storage usage for which separate statistics need to be returned. All other chats will be grouped in entries with chat_id == 0. If the chat info database is not used, the chat_limit is ignored and is always set to 0
    }
  deriving (GetStorageStatistics -> GetStorageStatistics -> Bool
(GetStorageStatistics -> GetStorageStatistics -> Bool)
-> (GetStorageStatistics -> GetStorageStatistics -> Bool)
-> Eq GetStorageStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStorageStatistics -> GetStorageStatistics -> Bool
== :: GetStorageStatistics -> GetStorageStatistics -> Bool
$c/= :: GetStorageStatistics -> GetStorageStatistics -> Bool
/= :: GetStorageStatistics -> GetStorageStatistics -> Bool
Eq, Int -> GetStorageStatistics -> ShowS
[GetStorageStatistics] -> ShowS
GetStorageStatistics -> String
(Int -> GetStorageStatistics -> ShowS)
-> (GetStorageStatistics -> String)
-> ([GetStorageStatistics] -> ShowS)
-> Show GetStorageStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStorageStatistics -> ShowS
showsPrec :: Int -> GetStorageStatistics -> ShowS
$cshow :: GetStorageStatistics -> String
show :: GetStorageStatistics -> String
$cshowList :: [GetStorageStatistics] -> ShowS
showList :: [GetStorageStatistics] -> ShowS
Show)

instance I.ShortShow GetStorageStatistics where
  shortShow :: GetStorageStatistics -> String
shortShow
    GetStorageStatistics
      { chat_limit :: GetStorageStatistics -> Maybe Int
chat_limit = Maybe Int
chat_limit_
      }
        = String
"GetStorageStatistics"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_limit" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_limit_
          ]

instance AT.ToJSON GetStorageStatistics where
  toJSON :: GetStorageStatistics -> Value
toJSON
    GetStorageStatistics
      { chat_limit :: GetStorageStatistics -> Maybe Int
chat_limit = Maybe Int
chat_limit_
      }
        = [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
"getStorageStatistics"
          , Key
"chat_limit" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
chat_limit_
          ]