module TD.Query.DeleteForumTopic
  (DeleteForumTopic(..)
  , defaultDeleteForumTopic
  ) where

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

-- | Deletes all messages in a forum topic; requires can_delete_messages administrator right in the supergroup unless the user is creator of the topic, the topic has no messages from other users and has at most 11 messages. Returns 'TD.Data.Ok.Ok'
data DeleteForumTopic
  = DeleteForumTopic
    { DeleteForumTopic -> Maybe Int
chat_id           :: Maybe Int -- ^ Identifier of the chat
    , DeleteForumTopic -> Maybe Int
message_thread_id :: Maybe Int -- ^ Message thread identifier of the forum topic
    }
  deriving (DeleteForumTopic -> DeleteForumTopic -> Bool
(DeleteForumTopic -> DeleteForumTopic -> Bool)
-> (DeleteForumTopic -> DeleteForumTopic -> Bool)
-> Eq DeleteForumTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteForumTopic -> DeleteForumTopic -> Bool
== :: DeleteForumTopic -> DeleteForumTopic -> Bool
$c/= :: DeleteForumTopic -> DeleteForumTopic -> Bool
/= :: DeleteForumTopic -> DeleteForumTopic -> Bool
Eq, Int -> DeleteForumTopic -> ShowS
[DeleteForumTopic] -> ShowS
DeleteForumTopic -> String
(Int -> DeleteForumTopic -> ShowS)
-> (DeleteForumTopic -> String)
-> ([DeleteForumTopic] -> ShowS)
-> Show DeleteForumTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteForumTopic -> ShowS
showsPrec :: Int -> DeleteForumTopic -> ShowS
$cshow :: DeleteForumTopic -> String
show :: DeleteForumTopic -> String
$cshowList :: [DeleteForumTopic] -> ShowS
showList :: [DeleteForumTopic] -> ShowS
Show)

instance I.ShortShow DeleteForumTopic where
  shortShow :: DeleteForumTopic -> String
shortShow
    DeleteForumTopic
      { chat_id :: DeleteForumTopic -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: DeleteForumTopic -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      }
        = String
"DeleteForumTopic"
          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
"message_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
          ]

instance AT.ToJSON DeleteForumTopic where
  toJSON :: DeleteForumTopic -> Value
toJSON
    DeleteForumTopic
      { chat_id :: DeleteForumTopic -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: DeleteForumTopic -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      }
        = [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
"deleteForumTopic"
          , 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
"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
message_thread_id_
          ]

defaultDeleteForumTopic :: DeleteForumTopic
defaultDeleteForumTopic :: DeleteForumTopic
defaultDeleteForumTopic =
  DeleteForumTopic
    { chat_id :: Maybe Int
chat_id           = Maybe Int
forall a. Maybe a
Nothing
    , message_thread_id :: Maybe Int
message_thread_id = Maybe Int
forall a. Maybe a
Nothing
    }