module TD.Query.GetDirectMessagesChatTopicHistory
  (GetDirectMessagesChatTopicHistory(..)
  , defaultGetDirectMessagesChatTopicHistory
  ) where

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

-- | Returns messages in the topic in a channel direct messages chat administered by the current user. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). Returns 'TD.Data.Messages.Messages'
data GetDirectMessagesChatTopicHistory
  = GetDirectMessagesChatTopicHistory
    { GetDirectMessagesChatTopicHistory -> Maybe Int
chat_id         :: Maybe Int -- ^ Chat identifier of the channel direct messages chat
    , GetDirectMessagesChatTopicHistory -> Maybe Int
topic_id        :: Maybe Int -- ^ Identifier of the topic which messages will be fetched
    , GetDirectMessagesChatTopicHistory -> Maybe Int
from_message_id :: Maybe Int -- ^ Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message
    , GetDirectMessagesChatTopicHistory -> Maybe Int
offset          :: Maybe Int -- ^ Specify 0 to get results from exactly the message from_message_id or a negative offset up to 99 to get additionally some newer messages
    , GetDirectMessagesChatTopicHistory -> Maybe Int
limit           :: Maybe Int -- ^ The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
    }
  deriving (GetDirectMessagesChatTopicHistory
-> GetDirectMessagesChatTopicHistory -> Bool
(GetDirectMessagesChatTopicHistory
 -> GetDirectMessagesChatTopicHistory -> Bool)
-> (GetDirectMessagesChatTopicHistory
    -> GetDirectMessagesChatTopicHistory -> Bool)
-> Eq GetDirectMessagesChatTopicHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetDirectMessagesChatTopicHistory
-> GetDirectMessagesChatTopicHistory -> Bool
== :: GetDirectMessagesChatTopicHistory
-> GetDirectMessagesChatTopicHistory -> Bool
$c/= :: GetDirectMessagesChatTopicHistory
-> GetDirectMessagesChatTopicHistory -> Bool
/= :: GetDirectMessagesChatTopicHistory
-> GetDirectMessagesChatTopicHistory -> Bool
Eq, Int -> GetDirectMessagesChatTopicHistory -> ShowS
[GetDirectMessagesChatTopicHistory] -> ShowS
GetDirectMessagesChatTopicHistory -> String
(Int -> GetDirectMessagesChatTopicHistory -> ShowS)
-> (GetDirectMessagesChatTopicHistory -> String)
-> ([GetDirectMessagesChatTopicHistory] -> ShowS)
-> Show GetDirectMessagesChatTopicHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetDirectMessagesChatTopicHistory -> ShowS
showsPrec :: Int -> GetDirectMessagesChatTopicHistory -> ShowS
$cshow :: GetDirectMessagesChatTopicHistory -> String
show :: GetDirectMessagesChatTopicHistory -> String
$cshowList :: [GetDirectMessagesChatTopicHistory] -> ShowS
showList :: [GetDirectMessagesChatTopicHistory] -> ShowS
Show)

instance I.ShortShow GetDirectMessagesChatTopicHistory where
  shortShow :: GetDirectMessagesChatTopicHistory -> String
shortShow
    GetDirectMessagesChatTopicHistory
      { chat_id :: GetDirectMessagesChatTopicHistory -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , topic_id :: GetDirectMessagesChatTopicHistory -> Maybe Int
topic_id        = Maybe Int
topic_id_
      , from_message_id :: GetDirectMessagesChatTopicHistory -> Maybe Int
from_message_id = Maybe Int
from_message_id_
      , offset :: GetDirectMessagesChatTopicHistory -> Maybe Int
offset          = Maybe Int
offset_
      , limit :: GetDirectMessagesChatTopicHistory -> Maybe Int
limit           = Maybe Int
limit_
      }
        = String
"GetDirectMessagesChatTopicHistory"
          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
"topic_id"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
topic_id_
          , String
"from_message_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
from_message_id_
          , String
"offset"          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_
          , String
"limit"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetDirectMessagesChatTopicHistory where
  toJSON :: GetDirectMessagesChatTopicHistory -> Value
toJSON
    GetDirectMessagesChatTopicHistory
      { chat_id :: GetDirectMessagesChatTopicHistory -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , topic_id :: GetDirectMessagesChatTopicHistory -> Maybe Int
topic_id        = Maybe Int
topic_id_
      , from_message_id :: GetDirectMessagesChatTopicHistory -> Maybe Int
from_message_id = Maybe Int
from_message_id_
      , offset :: GetDirectMessagesChatTopicHistory -> Maybe Int
offset          = Maybe Int
offset_
      , limit :: GetDirectMessagesChatTopicHistory -> 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
"getDirectMessagesChatTopicHistory"
          , 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
"topic_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
topic_id_
          , Key
"from_message_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
from_message_id_
          , Key
"offset"          Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
offset_
          , 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_
          ]

defaultGetDirectMessagesChatTopicHistory :: GetDirectMessagesChatTopicHistory
defaultGetDirectMessagesChatTopicHistory :: GetDirectMessagesChatTopicHistory
defaultGetDirectMessagesChatTopicHistory =
  GetDirectMessagesChatTopicHistory
    { chat_id :: Maybe Int
chat_id         = Maybe Int
forall a. Maybe a
Nothing
    , topic_id :: Maybe Int
topic_id        = Maybe Int
forall a. Maybe a
Nothing
    , from_message_id :: Maybe Int
from_message_id = Maybe Int
forall a. Maybe a
Nothing
    , offset :: Maybe Int
offset          = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit           = Maybe Int
forall a. Maybe a
Nothing
    }