module TD.Query.GetChatStatistics
  (GetChatStatistics(..)
  , defaultGetChatStatistics
  ) where

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

-- | Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true. Returns 'TD.Data.ChatStatistics.ChatStatistics'
data GetChatStatistics
  = GetChatStatistics
    { GetChatStatistics -> Maybe Int
chat_id :: Maybe Int  -- ^ Chat identifier
    , GetChatStatistics -> Maybe Bool
is_dark :: Maybe Bool -- ^ Pass true if a dark theme is used by the application
    }
  deriving (GetChatStatistics -> GetChatStatistics -> Bool
(GetChatStatistics -> GetChatStatistics -> Bool)
-> (GetChatStatistics -> GetChatStatistics -> Bool)
-> Eq GetChatStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatStatistics -> GetChatStatistics -> Bool
== :: GetChatStatistics -> GetChatStatistics -> Bool
$c/= :: GetChatStatistics -> GetChatStatistics -> Bool
/= :: GetChatStatistics -> GetChatStatistics -> Bool
Eq, Int -> GetChatStatistics -> ShowS
[GetChatStatistics] -> ShowS
GetChatStatistics -> String
(Int -> GetChatStatistics -> ShowS)
-> (GetChatStatistics -> String)
-> ([GetChatStatistics] -> ShowS)
-> Show GetChatStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatStatistics -> ShowS
showsPrec :: Int -> GetChatStatistics -> ShowS
$cshow :: GetChatStatistics -> String
show :: GetChatStatistics -> String
$cshowList :: [GetChatStatistics] -> ShowS
showList :: [GetChatStatistics] -> ShowS
Show)

instance I.ShortShow GetChatStatistics where
  shortShow :: GetChatStatistics -> String
shortShow
    GetChatStatistics
      { chat_id :: GetChatStatistics -> Maybe Int
chat_id = Maybe Int
chat_id_
      , is_dark :: GetChatStatistics -> Maybe Bool
is_dark = Maybe Bool
is_dark_
      }
        = String
"GetChatStatistics"
          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
"is_dark" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_dark_
          ]

instance AT.ToJSON GetChatStatistics where
  toJSON :: GetChatStatistics -> Value
toJSON
    GetChatStatistics
      { chat_id :: GetChatStatistics -> Maybe Int
chat_id = Maybe Int
chat_id_
      , is_dark :: GetChatStatistics -> Maybe Bool
is_dark = Maybe Bool
is_dark_
      }
        = [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
"getChatStatistics"
          , Key
"chat_id" 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_id_
          , Key
"is_dark" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_dark_
          ]

defaultGetChatStatistics :: GetChatStatistics
defaultGetChatStatistics :: GetChatStatistics
defaultGetChatStatistics =
  GetChatStatistics
    { chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
    , is_dark :: Maybe Bool
is_dark = Maybe Bool
forall a. Maybe a
Nothing
    }