module TD.Query.GetChatSimilarChatCount
  (GetChatSimilarChatCount(..)
  , defaultGetChatSimilarChatCount
  ) where

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

-- | Returns approximate number of chats similar to the given chat. Returns 'TD.Data.Count.Count'
data GetChatSimilarChatCount
  = GetChatSimilarChatCount
    { GetChatSimilarChatCount -> Maybe Int
chat_id      :: Maybe Int  -- ^ Identifier of the target chat; must be an identifier of a channel chat
    , GetChatSimilarChatCount -> Maybe Bool
return_local :: Maybe Bool -- ^ Pass true to get the number of chats without sending network requests, or -1 if the number of chats is unknown locally
    }
  deriving (GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool
(GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool)
-> (GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool)
-> Eq GetChatSimilarChatCount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool
== :: GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool
$c/= :: GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool
/= :: GetChatSimilarChatCount -> GetChatSimilarChatCount -> Bool
Eq, Int -> GetChatSimilarChatCount -> ShowS
[GetChatSimilarChatCount] -> ShowS
GetChatSimilarChatCount -> String
(Int -> GetChatSimilarChatCount -> ShowS)
-> (GetChatSimilarChatCount -> String)
-> ([GetChatSimilarChatCount] -> ShowS)
-> Show GetChatSimilarChatCount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatSimilarChatCount -> ShowS
showsPrec :: Int -> GetChatSimilarChatCount -> ShowS
$cshow :: GetChatSimilarChatCount -> String
show :: GetChatSimilarChatCount -> String
$cshowList :: [GetChatSimilarChatCount] -> ShowS
showList :: [GetChatSimilarChatCount] -> ShowS
Show)

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

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

defaultGetChatSimilarChatCount :: GetChatSimilarChatCount
defaultGetChatSimilarChatCount :: GetChatSimilarChatCount
defaultGetChatSimilarChatCount =
  GetChatSimilarChatCount
    { chat_id :: Maybe Int
chat_id      = Maybe Int
forall a. Maybe a
Nothing
    , return_local :: Maybe Bool
return_local = Maybe Bool
forall a. Maybe a
Nothing
    }