module TD.Query.ToggleForumTopicIsClosed
  (ToggleForumTopicIsClosed(..)
  , defaultToggleForumTopicIsClosed
  ) where

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

-- | Toggles whether a topic is closed in a forum supergroup chat; requires can_manage_topics right in the supergroup unless the user is creator of the topic. Returns 'TD.Data.Ok.Ok'
data ToggleForumTopicIsClosed
  = ToggleForumTopicIsClosed
    { ToggleForumTopicIsClosed -> Maybe Int
chat_id           :: Maybe Int  -- ^ Identifier of the chat
    , ToggleForumTopicIsClosed -> Maybe Int
message_thread_id :: Maybe Int  -- ^ Message thread identifier of the forum topic
    , ToggleForumTopicIsClosed -> Maybe Bool
is_closed         :: Maybe Bool -- ^ Pass true to close the topic; pass false to reopen it
    }
  deriving (ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool
(ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool)
-> (ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool)
-> Eq ToggleForumTopicIsClosed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool
== :: ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool
$c/= :: ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool
/= :: ToggleForumTopicIsClosed -> ToggleForumTopicIsClosed -> Bool
Eq, Int -> ToggleForumTopicIsClosed -> ShowS
[ToggleForumTopicIsClosed] -> ShowS
ToggleForumTopicIsClosed -> String
(Int -> ToggleForumTopicIsClosed -> ShowS)
-> (ToggleForumTopicIsClosed -> String)
-> ([ToggleForumTopicIsClosed] -> ShowS)
-> Show ToggleForumTopicIsClosed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleForumTopicIsClosed -> ShowS
showsPrec :: Int -> ToggleForumTopicIsClosed -> ShowS
$cshow :: ToggleForumTopicIsClosed -> String
show :: ToggleForumTopicIsClosed -> String
$cshowList :: [ToggleForumTopicIsClosed] -> ShowS
showList :: [ToggleForumTopicIsClosed] -> ShowS
Show)

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

instance AT.ToJSON ToggleForumTopicIsClosed where
  toJSON :: ToggleForumTopicIsClosed -> Value
toJSON
    ToggleForumTopicIsClosed
      { chat_id :: ToggleForumTopicIsClosed -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: ToggleForumTopicIsClosed -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      , is_closed :: ToggleForumTopicIsClosed -> Maybe Bool
is_closed         = Maybe Bool
is_closed_
      }
        = [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
"toggleForumTopicIsClosed"
          , 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_
          , Key
"is_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
is_closed_
          ]

defaultToggleForumTopicIsClosed :: ToggleForumTopicIsClosed
defaultToggleForumTopicIsClosed :: ToggleForumTopicIsClosed
defaultToggleForumTopicIsClosed =
  ToggleForumTopicIsClosed
    { 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
    , is_closed :: Maybe Bool
is_closed         = Maybe Bool
forall a. Maybe a
Nothing
    }