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 supergroup chat or a chat with a bot with topics. This is a temporary method for getting information about the topic list from the server. Returns 'TD.Data.ForumTopics.ForumTopics'
data GetForumTopics
  = GetForumTopics
    { GetForumTopics -> Maybe Int
chat_id               :: Maybe Int    -- ^ Identifier of the chat
    , GetForumTopics -> Maybe Text
query                 :: Maybe T.Text -- ^ Query to search for in the forum topic's name
    , GetForumTopics -> Maybe Int
icon_custom_emoji_id  :: Maybe Int    -- ^ If non-zero, then only topics with the icon with the given custom emoji identifier will be returned; must be 0 in chats with bots
    , GetForumTopics -> Maybe Bool
exclude_open          :: Maybe Bool   -- ^ Pass true to exclude open topics; must be false in chats with bots
    , GetForumTopics -> Maybe Bool
exclude_closed        :: Maybe Bool   -- ^ Pass true to exclude closed topics; must be false in chats with bots
    , 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_forum_topic_id :: Maybe Int    -- ^ The forum topic 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_
      , icon_custom_emoji_id :: GetForumTopics -> Maybe Int
icon_custom_emoji_id  = Maybe Int
icon_custom_emoji_id_
      , exclude_open :: GetForumTopics -> Maybe Bool
exclude_open          = Maybe Bool
exclude_open_
      , exclude_closed :: GetForumTopics -> Maybe Bool
exclude_closed        = Maybe Bool
exclude_closed_
      , 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_forum_topic_id :: GetForumTopics -> Maybe Int
offset_forum_topic_id = Maybe Int
offset_forum_topic_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
"icon_custom_emoji_id"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
icon_custom_emoji_id_
          , String
"exclude_open"          String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_open_
          , String
"exclude_closed"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_closed_
          , 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_forum_topic_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_forum_topic_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_
      , icon_custom_emoji_id :: GetForumTopics -> Maybe Int
icon_custom_emoji_id  = Maybe Int
icon_custom_emoji_id_
      , exclude_open :: GetForumTopics -> Maybe Bool
exclude_open          = Maybe Bool
exclude_open_
      , exclude_closed :: GetForumTopics -> Maybe Bool
exclude_closed        = Maybe Bool
exclude_closed_
      , 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_forum_topic_id :: GetForumTopics -> Maybe Int
offset_forum_topic_id = Maybe Int
offset_forum_topic_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
"icon_custom_emoji_id"  Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
icon_custom_emoji_id_
          , Key
"exclude_open"          Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_open_
          , Key
"exclude_closed"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_closed_
          , 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_forum_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
offset_forum_topic_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
    , icon_custom_emoji_id :: Maybe Int
icon_custom_emoji_id  = Maybe Int
forall a. Maybe a
Nothing
    , exclude_open :: Maybe Bool
exclude_open          = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_closed :: Maybe Bool
exclude_closed        = Maybe Bool
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_forum_topic_id :: Maybe Int
offset_forum_topic_id = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit                 = Maybe Int
forall a. Maybe a
Nothing
    }