module TD.Query.GetRecentlyOpenedChats
  (GetRecentlyOpenedChats(..)
  ) where

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

-- | Returns recently opened chats; this is an offline request. Returns chats in the order of last opening. Returns 'TD.Data.Chats.Chats'
data GetRecentlyOpenedChats
  = GetRecentlyOpenedChats
    { GetRecentlyOpenedChats -> Maybe Int
limit :: Maybe Int -- ^ The maximum number of chats to be returned
    }
  deriving (GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool
(GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool)
-> (GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool)
-> Eq GetRecentlyOpenedChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool
== :: GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool
$c/= :: GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool
/= :: GetRecentlyOpenedChats -> GetRecentlyOpenedChats -> Bool
Eq, Int -> GetRecentlyOpenedChats -> ShowS
[GetRecentlyOpenedChats] -> ShowS
GetRecentlyOpenedChats -> String
(Int -> GetRecentlyOpenedChats -> ShowS)
-> (GetRecentlyOpenedChats -> String)
-> ([GetRecentlyOpenedChats] -> ShowS)
-> Show GetRecentlyOpenedChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetRecentlyOpenedChats -> ShowS
showsPrec :: Int -> GetRecentlyOpenedChats -> ShowS
$cshow :: GetRecentlyOpenedChats -> String
show :: GetRecentlyOpenedChats -> String
$cshowList :: [GetRecentlyOpenedChats] -> ShowS
showList :: [GetRecentlyOpenedChats] -> ShowS
Show)

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

instance AT.ToJSON GetRecentlyOpenedChats where
  toJSON :: GetRecentlyOpenedChats -> Value
toJSON
    GetRecentlyOpenedChats
      { limit :: GetRecentlyOpenedChats -> 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
"getRecentlyOpenedChats"
          , 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_
          ]