module TD.Query.GetTopChats
  (GetTopChats(..)
  , defaultGetTopChats
  ) 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.TopChatCategory as TopChatCategory

-- | Returns a list of frequently used chats. Returns 'TD.Data.Chats.Chats'
data GetTopChats
  = GetTopChats
    { GetTopChats -> Maybe TopChatCategory
category :: Maybe TopChatCategory.TopChatCategory -- ^ Category of chats to be returned
    , GetTopChats -> Maybe Int
limit    :: Maybe Int                             -- ^ The maximum number of chats to be returned; up to 30
    }
  deriving (GetTopChats -> GetTopChats -> Bool
(GetTopChats -> GetTopChats -> Bool)
-> (GetTopChats -> GetTopChats -> Bool) -> Eq GetTopChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTopChats -> GetTopChats -> Bool
== :: GetTopChats -> GetTopChats -> Bool
$c/= :: GetTopChats -> GetTopChats -> Bool
/= :: GetTopChats -> GetTopChats -> Bool
Eq, Int -> GetTopChats -> ShowS
[GetTopChats] -> ShowS
GetTopChats -> String
(Int -> GetTopChats -> ShowS)
-> (GetTopChats -> String)
-> ([GetTopChats] -> ShowS)
-> Show GetTopChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTopChats -> ShowS
showsPrec :: Int -> GetTopChats -> ShowS
$cshow :: GetTopChats -> String
show :: GetTopChats -> String
$cshowList :: [GetTopChats] -> ShowS
showList :: [GetTopChats] -> ShowS
Show)

instance I.ShortShow GetTopChats where
  shortShow :: GetTopChats -> String
shortShow
    GetTopChats
      { category :: GetTopChats -> Maybe TopChatCategory
category = Maybe TopChatCategory
category_
      , limit :: GetTopChats -> Maybe Int
limit    = Maybe Int
limit_
      }
        = String
"GetTopChats"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"category" String -> Maybe TopChatCategory -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TopChatCategory
category_
          , String
"limit"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetTopChats where
  toJSON :: GetTopChats -> Value
toJSON
    GetTopChats
      { category :: GetTopChats -> Maybe TopChatCategory
category = Maybe TopChatCategory
category_
      , limit :: GetTopChats -> Maybe Int
limit    = Maybe Int
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
"getTopChats"
          , Key
"category" Key -> Maybe TopChatCategory -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe TopChatCategory
category_
          , Key
"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
limit_
          ]

defaultGetTopChats :: GetTopChats
defaultGetTopChats :: GetTopChats
defaultGetTopChats =
  GetTopChats
    { category :: Maybe TopChatCategory
category = Maybe TopChatCategory
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit    = Maybe Int
forall a. Maybe a
Nothing
    }