module TD.Query.UnpinAllForumTopicMessages
  (UnpinAllForumTopicMessages(..)
  , defaultUnpinAllForumTopicMessages
  ) where

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

-- | Removes all pinned messages from a topic in a forum supergroup chat or a chat with a bot with topics; requires can_pin_messages member right in the supergroup. Returns 'TD.Data.Ok.Ok'
data UnpinAllForumTopicMessages
  = UnpinAllForumTopicMessages
    { UnpinAllForumTopicMessages -> Maybe Int
chat_id        :: Maybe Int -- ^ Identifier of the chat
    , UnpinAllForumTopicMessages -> Maybe Int
forum_topic_id :: Maybe Int -- ^ Forum topic identifier in which messages will be unpinned
    }
  deriving (UnpinAllForumTopicMessages -> UnpinAllForumTopicMessages -> Bool
(UnpinAllForumTopicMessages -> UnpinAllForumTopicMessages -> Bool)
-> (UnpinAllForumTopicMessages
    -> UnpinAllForumTopicMessages -> Bool)
-> Eq UnpinAllForumTopicMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnpinAllForumTopicMessages -> UnpinAllForumTopicMessages -> Bool
== :: UnpinAllForumTopicMessages -> UnpinAllForumTopicMessages -> Bool
$c/= :: UnpinAllForumTopicMessages -> UnpinAllForumTopicMessages -> Bool
/= :: UnpinAllForumTopicMessages -> UnpinAllForumTopicMessages -> Bool
Eq, Int -> UnpinAllForumTopicMessages -> ShowS
[UnpinAllForumTopicMessages] -> ShowS
UnpinAllForumTopicMessages -> String
(Int -> UnpinAllForumTopicMessages -> ShowS)
-> (UnpinAllForumTopicMessages -> String)
-> ([UnpinAllForumTopicMessages] -> ShowS)
-> Show UnpinAllForumTopicMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnpinAllForumTopicMessages -> ShowS
showsPrec :: Int -> UnpinAllForumTopicMessages -> ShowS
$cshow :: UnpinAllForumTopicMessages -> String
show :: UnpinAllForumTopicMessages -> String
$cshowList :: [UnpinAllForumTopicMessages] -> ShowS
showList :: [UnpinAllForumTopicMessages] -> ShowS
Show)

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

instance AT.ToJSON UnpinAllForumTopicMessages where
  toJSON :: UnpinAllForumTopicMessages -> Value
toJSON
    UnpinAllForumTopicMessages
      { chat_id :: UnpinAllForumTopicMessages -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , forum_topic_id :: UnpinAllForumTopicMessages -> Maybe Int
forum_topic_id = Maybe Int
forum_topic_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
"unpinAllForumTopicMessages"
          , 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
"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
forum_topic_id_
          ]

defaultUnpinAllForumTopicMessages :: UnpinAllForumTopicMessages
defaultUnpinAllForumTopicMessages :: UnpinAllForumTopicMessages
defaultUnpinAllForumTopicMessages =
  UnpinAllForumTopicMessages
    { chat_id :: Maybe Int
chat_id        = Maybe Int
forall a. Maybe a
Nothing
    , forum_topic_id :: Maybe Int
forum_topic_id = Maybe Int
forall a. Maybe a
Nothing
    }