module TD.Query.ToggleChatIsPinned
  (ToggleChatIsPinned(..)
  , defaultToggleChatIsPinned
  ) where

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

-- | Changes the pinned state of a chat. There can be up to getOption("pinned_chat_count_max")/getOption("pinned_archived_chat_count_max") pinned non-secret chats and the same number of secret chats in the main/archive chat list. The limit can be increased with Telegram Premium. Returns 'TD.Data.Ok.Ok'
data ToggleChatIsPinned
  = ToggleChatIsPinned
    { ToggleChatIsPinned -> Maybe ChatList
chat_list :: Maybe ChatList.ChatList -- ^ Chat list in which to change the pinned state of the chat
    , ToggleChatIsPinned -> Maybe Int
chat_id   :: Maybe Int               -- ^ Chat identifier
    , ToggleChatIsPinned -> Maybe Bool
is_pinned :: Maybe Bool              -- ^ Pass true to pin the chat; pass false to unpin it
    }
  deriving (ToggleChatIsPinned -> ToggleChatIsPinned -> Bool
(ToggleChatIsPinned -> ToggleChatIsPinned -> Bool)
-> (ToggleChatIsPinned -> ToggleChatIsPinned -> Bool)
-> Eq ToggleChatIsPinned
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleChatIsPinned -> ToggleChatIsPinned -> Bool
== :: ToggleChatIsPinned -> ToggleChatIsPinned -> Bool
$c/= :: ToggleChatIsPinned -> ToggleChatIsPinned -> Bool
/= :: ToggleChatIsPinned -> ToggleChatIsPinned -> Bool
Eq, Int -> ToggleChatIsPinned -> ShowS
[ToggleChatIsPinned] -> ShowS
ToggleChatIsPinned -> String
(Int -> ToggleChatIsPinned -> ShowS)
-> (ToggleChatIsPinned -> String)
-> ([ToggleChatIsPinned] -> ShowS)
-> Show ToggleChatIsPinned
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleChatIsPinned -> ShowS
showsPrec :: Int -> ToggleChatIsPinned -> ShowS
$cshow :: ToggleChatIsPinned -> String
show :: ToggleChatIsPinned -> String
$cshowList :: [ToggleChatIsPinned] -> ShowS
showList :: [ToggleChatIsPinned] -> ShowS
Show)

instance I.ShortShow ToggleChatIsPinned where
  shortShow :: ToggleChatIsPinned -> String
shortShow
    ToggleChatIsPinned
      { chat_list :: ToggleChatIsPinned -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      , chat_id :: ToggleChatIsPinned -> Maybe Int
chat_id   = Maybe Int
chat_id_
      , is_pinned :: ToggleChatIsPinned -> Maybe Bool
is_pinned = Maybe Bool
is_pinned_
      }
        = String
"ToggleChatIsPinned"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_list" String -> Maybe ChatList -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatList
chat_list_
          , String
"chat_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_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 ToggleChatIsPinned where
  toJSON :: ToggleChatIsPinned -> Value
toJSON
    ToggleChatIsPinned
      { chat_list :: ToggleChatIsPinned -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      , chat_id :: ToggleChatIsPinned -> Maybe Int
chat_id   = Maybe Int
chat_id_
      , is_pinned :: ToggleChatIsPinned -> 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
"toggleChatIsPinned"
          , Key
"chat_list" Key -> Maybe ChatList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatList
chat_list_
          , 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
"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_
          ]

defaultToggleChatIsPinned :: ToggleChatIsPinned
defaultToggleChatIsPinned :: ToggleChatIsPinned
defaultToggleChatIsPinned =
  ToggleChatIsPinned
    { chat_list :: Maybe ChatList
chat_list = Maybe ChatList
forall a. Maybe a
Nothing
    , chat_id :: Maybe Int
chat_id   = Maybe Int
forall a. Maybe a
Nothing
    , is_pinned :: Maybe Bool
is_pinned = Maybe Bool
forall a. Maybe a
Nothing
    }