module TD.Query.GetForumTopics
  (GetForumTopics(..)
  , defaultGetForumTopics
  ) where

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

-- | Returns found forum topics in a forum chat. This is a temporary method for getting information about topic list from the server. Returns 'TD.Data.ForumTopics.ForumTopics'
data GetForumTopics
  = GetForumTopics
    { GetForumTopics -> Maybe Int
chat_id                  :: Maybe Int    -- ^ Identifier of the forum chat
    , GetForumTopics -> Maybe Text
query                    :: Maybe T.Text -- ^ Query to search for in the forum topic's name
    , GetForumTopics -> Maybe Int
offset_date              :: Maybe Int    -- ^ The date starting from which the results need to be fetched. Use 0 or any date in the future to get results from the last topic
    , GetForumTopics -> Maybe Int
offset_message_id        :: Maybe Int    -- ^ The message identifier of the last message in the last found topic, or 0 for the first request
    , GetForumTopics -> Maybe Int
offset_message_thread_id :: Maybe Int    -- ^ The message thread identifier of the last found topic, or 0 for the first request
    , GetForumTopics -> Maybe Int
limit                    :: Maybe Int    -- ^ The maximum number of forum topics to be returned; up to 100. For optimal performance, the number of returned forum topics is chosen by TDLib and can be smaller than the specified limit
    }
  deriving (GetForumTopics -> GetForumTopics -> Bool
(GetForumTopics -> GetForumTopics -> Bool)
-> (GetForumTopics -> GetForumTopics -> Bool) -> Eq GetForumTopics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetForumTopics -> GetForumTopics -> Bool
== :: GetForumTopics -> GetForumTopics -> Bool
$c/= :: GetForumTopics -> GetForumTopics -> Bool
/= :: GetForumTopics -> GetForumTopics -> Bool
Eq, Int -> GetForumTopics -> ShowS
[GetForumTopics] -> ShowS
GetForumTopics -> String
(Int -> GetForumTopics -> ShowS)
-> (GetForumTopics -> String)
-> ([GetForumTopics] -> ShowS)
-> Show GetForumTopics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetForumTopics -> ShowS
showsPrec :: Int -> GetForumTopics -> ShowS
$cshow :: GetForumTopics -> String
show :: GetForumTopics -> String
$cshowList :: [GetForumTopics] -> ShowS
showList :: [GetForumTopics] -> ShowS
Show)

instance I.ShortShow GetForumTopics where
  shortShow :: GetForumTopics -> String
shortShow
    GetForumTopics
      { chat_id :: GetForumTopics -> Maybe Int
chat_id                  = Maybe Int
chat_id_
      , query :: GetForumTopics -> Maybe Text
query                    = Maybe Text
query_
      , offset_date :: GetForumTopics -> Maybe Int
offset_date              = Maybe Int
offset_date_
      , offset_message_id :: GetForumTopics -> Maybe Int
offset_message_id        = Maybe Int
offset_message_id_
      , offset_message_thread_id :: GetForumTopics -> Maybe Int
offset_message_thread_id = Maybe Int
offset_message_thread_id_
      , limit :: GetForumTopics -> Maybe Int
limit                    = Maybe Int
limit_
      }
        = String
"GetForumTopics"
          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
"query"                    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
          , String
"offset_date"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_date_
          , String
"offset_message_id"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_message_id_
          , String
"offset_message_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_message_thread_id_
          , String
"limit"                    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetForumTopics where
  toJSON :: GetForumTopics -> Value
toJSON
    GetForumTopics
      { chat_id :: GetForumTopics -> Maybe Int
chat_id                  = Maybe Int
chat_id_
      , query :: GetForumTopics -> Maybe Text
query                    = Maybe Text
query_
      , offset_date :: GetForumTopics -> Maybe Int
offset_date              = Maybe Int
offset_date_
      , offset_message_id :: GetForumTopics -> Maybe Int
offset_message_id        = Maybe Int
offset_message_id_
      , offset_message_thread_id :: GetForumTopics -> Maybe Int
offset_message_thread_id = Maybe Int
offset_message_thread_id_
      , limit :: GetForumTopics -> 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
"getForumTopics"
          , 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
"query"                    Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
          , Key
"offset_date"              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_date_
          , Key
"offset_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
offset_message_id_
          , Key
"offset_message_thread_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
offset_message_thread_id_
          , 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_
          ]

defaultGetForumTopics :: GetForumTopics
defaultGetForumTopics :: GetForumTopics
defaultGetForumTopics =
  GetForumTopics
    { chat_id :: Maybe Int
chat_id                  = Maybe Int
forall a. Maybe a
Nothing
    , query :: Maybe Text
query                    = Maybe Text
forall a. Maybe a
Nothing
    , offset_date :: Maybe Int
offset_date              = Maybe Int
forall a. Maybe a
Nothing
    , offset_message_id :: Maybe Int
offset_message_id        = Maybe Int
forall a. Maybe a
Nothing
    , offset_message_thread_id :: Maybe Int
offset_message_thread_id = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit                    = Maybe Int
forall a. Maybe a
Nothing
    }