module TD.Query.SetPinnedForumTopics
  (SetPinnedForumTopics(..)
  , defaultSetPinnedForumTopics
  ) where

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

-- | Changes the order of pinned forum topics; requires can_manage_topics right in the supergroup. Returns 'TD.Data.Ok.Ok'
data SetPinnedForumTopics
  = SetPinnedForumTopics
    { SetPinnedForumTopics -> Maybe Int
chat_id            :: Maybe Int   -- ^ Chat identifier
    , SetPinnedForumTopics -> Maybe [Int]
message_thread_ids :: Maybe [Int] -- ^ The new list of pinned forum topics
    }
  deriving (SetPinnedForumTopics -> SetPinnedForumTopics -> Bool
(SetPinnedForumTopics -> SetPinnedForumTopics -> Bool)
-> (SetPinnedForumTopics -> SetPinnedForumTopics -> Bool)
-> Eq SetPinnedForumTopics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetPinnedForumTopics -> SetPinnedForumTopics -> Bool
== :: SetPinnedForumTopics -> SetPinnedForumTopics -> Bool
$c/= :: SetPinnedForumTopics -> SetPinnedForumTopics -> Bool
/= :: SetPinnedForumTopics -> SetPinnedForumTopics -> Bool
Eq, Int -> SetPinnedForumTopics -> ShowS
[SetPinnedForumTopics] -> ShowS
SetPinnedForumTopics -> String
(Int -> SetPinnedForumTopics -> ShowS)
-> (SetPinnedForumTopics -> String)
-> ([SetPinnedForumTopics] -> ShowS)
-> Show SetPinnedForumTopics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetPinnedForumTopics -> ShowS
showsPrec :: Int -> SetPinnedForumTopics -> ShowS
$cshow :: SetPinnedForumTopics -> String
show :: SetPinnedForumTopics -> String
$cshowList :: [SetPinnedForumTopics] -> ShowS
showList :: [SetPinnedForumTopics] -> ShowS
Show)

instance I.ShortShow SetPinnedForumTopics where
  shortShow :: SetPinnedForumTopics -> String
shortShow
    SetPinnedForumTopics
      { chat_id :: SetPinnedForumTopics -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , message_thread_ids :: SetPinnedForumTopics -> Maybe [Int]
message_thread_ids = Maybe [Int]
message_thread_ids_
      }
        = String
"SetPinnedForumTopics"
          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_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
message_thread_ids_
          ]

instance AT.ToJSON SetPinnedForumTopics where
  toJSON :: SetPinnedForumTopics -> Value
toJSON
    SetPinnedForumTopics
      { chat_id :: SetPinnedForumTopics -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , message_thread_ids :: SetPinnedForumTopics -> Maybe [Int]
message_thread_ids = Maybe [Int]
message_thread_ids_
      }
        = [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
"setPinnedForumTopics"
          , 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_ids" 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_ids_
          ]

defaultSetPinnedForumTopics :: SetPinnedForumTopics
defaultSetPinnedForumTopics :: SetPinnedForumTopics
defaultSetPinnedForumTopics =
  SetPinnedForumTopics
    { chat_id :: Maybe Int
chat_id            = Maybe Int
forall a. Maybe a
Nothing
    , message_thread_ids :: Maybe [Int]
message_thread_ids = Maybe [Int]
forall a. Maybe a
Nothing
    }