module TD.Query.ToggleForumTopicIsPinned
  (ToggleForumTopicIsPinned(..)
  , defaultToggleForumTopicIsPinned
  ) where

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

-- | Changes the pinned state of a forum topic; requires can_manage_topics right in the supergroup. There can be up to getOption("pinned_forum_topic_count_max") pinned forum topics. Returns 'TD.Data.Ok.Ok'
data ToggleForumTopicIsPinned
  = ToggleForumTopicIsPinned
    { ToggleForumTopicIsPinned -> Maybe Int
chat_id           :: Maybe Int  -- ^ Chat identifier
    , ToggleForumTopicIsPinned -> Maybe Int
message_thread_id :: Maybe Int  -- ^ Message thread identifier of the forum topic
    , ToggleForumTopicIsPinned -> Maybe Bool
is_pinned         :: Maybe Bool -- ^ Pass true to pin the topic; pass false to unpin it
    }
  deriving (ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool
(ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool)
-> (ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool)
-> Eq ToggleForumTopicIsPinned
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool
== :: ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool
$c/= :: ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool
/= :: ToggleForumTopicIsPinned -> ToggleForumTopicIsPinned -> Bool
Eq, Int -> ToggleForumTopicIsPinned -> ShowS
[ToggleForumTopicIsPinned] -> ShowS
ToggleForumTopicIsPinned -> String
(Int -> ToggleForumTopicIsPinned -> ShowS)
-> (ToggleForumTopicIsPinned -> String)
-> ([ToggleForumTopicIsPinned] -> ShowS)
-> Show ToggleForumTopicIsPinned
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleForumTopicIsPinned -> ShowS
showsPrec :: Int -> ToggleForumTopicIsPinned -> ShowS
$cshow :: ToggleForumTopicIsPinned -> String
show :: ToggleForumTopicIsPinned -> String
$cshowList :: [ToggleForumTopicIsPinned] -> ShowS
showList :: [ToggleForumTopicIsPinned] -> ShowS
Show)

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

instance AT.ToJSON ToggleForumTopicIsPinned where
  toJSON :: ToggleForumTopicIsPinned -> Value
toJSON
    ToggleForumTopicIsPinned
      { chat_id :: ToggleForumTopicIsPinned -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: ToggleForumTopicIsPinned -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      , is_pinned :: ToggleForumTopicIsPinned -> Maybe Bool
is_pinned         = Maybe Bool
is_pinned_
      }
        = [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
"toggleForumTopicIsPinned"
          , 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_pinned"         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_pinned_
          ]

defaultToggleForumTopicIsPinned :: ToggleForumTopicIsPinned
defaultToggleForumTopicIsPinned :: ToggleForumTopicIsPinned
defaultToggleForumTopicIsPinned =
  ToggleForumTopicIsPinned
    { 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_pinned :: Maybe Bool
is_pinned         = Maybe Bool
forall a. Maybe a
Nothing
    }