module TD.Query.GetChats
  (GetChats(..)
  , defaultGetChats
  ) 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.ChatList as ChatList

-- | Returns an ordered list of chats from the beginning of a chat list. For informational purposes only. Use loadChats and updates processing instead to maintain chat lists in a consistent state. Returns 'TD.Data.Chats.Chats'
data GetChats
  = GetChats
    { GetChats -> Maybe ChatList
chat_list :: Maybe ChatList.ChatList -- ^ The chat list in which to return chats; pass null to get chats from the main chat list
    , GetChats -> Maybe Int
limit     :: Maybe Int               -- ^ The maximum number of chats to be returned
    }
  deriving (GetChats -> GetChats -> Bool
(GetChats -> GetChats -> Bool)
-> (GetChats -> GetChats -> Bool) -> Eq GetChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChats -> GetChats -> Bool
== :: GetChats -> GetChats -> Bool
$c/= :: GetChats -> GetChats -> Bool
/= :: GetChats -> GetChats -> Bool
Eq, Int -> GetChats -> ShowS
[GetChats] -> ShowS
GetChats -> String
(Int -> GetChats -> ShowS)
-> (GetChats -> String) -> ([GetChats] -> ShowS) -> Show GetChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChats -> ShowS
showsPrec :: Int -> GetChats -> ShowS
$cshow :: GetChats -> String
show :: GetChats -> String
$cshowList :: [GetChats] -> ShowS
showList :: [GetChats] -> ShowS
Show)

instance I.ShortShow GetChats where
  shortShow :: GetChats -> String
shortShow
    GetChats
      { chat_list :: GetChats -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      , limit :: GetChats -> Maybe Int
limit     = Maybe Int
limit_
      }
        = String
"GetChats"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_list" String -> Maybe ChatList -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatList
chat_list_
          , String
"limit"     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChats where
  toJSON :: GetChats -> Value
toJSON
    GetChats
      { chat_list :: GetChats -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      , limit :: GetChats -> 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
"getChats"
          , Key
"chat_list" Key -> Maybe ChatList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatList
chat_list_
          , 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_
          ]

defaultGetChats :: GetChats
defaultGetChats :: GetChats
defaultGetChats =
  GetChats
    { chat_list :: Maybe ChatList
chat_list = Maybe ChatList
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit     = Maybe Int
forall a. Maybe a
Nothing
    }