module TD.Query.RemoveTopChat
  (RemoveTopChat(..)
  , defaultRemoveTopChat
  ) 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.TopChatCategory as TopChatCategory

-- | Removes a chat from the list of frequently used chats. Supported only if the chat info database is enabled. Returns 'TD.Data.Ok.Ok'
data RemoveTopChat
  = RemoveTopChat
    { RemoveTopChat -> Maybe TopChatCategory
category :: Maybe TopChatCategory.TopChatCategory -- ^ Category of frequently used chats
    , RemoveTopChat -> Maybe Int
chat_id  :: Maybe Int                             -- ^ Chat identifier
    }
  deriving (RemoveTopChat -> RemoveTopChat -> Bool
(RemoveTopChat -> RemoveTopChat -> Bool)
-> (RemoveTopChat -> RemoveTopChat -> Bool) -> Eq RemoveTopChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveTopChat -> RemoveTopChat -> Bool
== :: RemoveTopChat -> RemoveTopChat -> Bool
$c/= :: RemoveTopChat -> RemoveTopChat -> Bool
/= :: RemoveTopChat -> RemoveTopChat -> Bool
Eq, Int -> RemoveTopChat -> ShowS
[RemoveTopChat] -> ShowS
RemoveTopChat -> String
(Int -> RemoveTopChat -> ShowS)
-> (RemoveTopChat -> String)
-> ([RemoveTopChat] -> ShowS)
-> Show RemoveTopChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveTopChat -> ShowS
showsPrec :: Int -> RemoveTopChat -> ShowS
$cshow :: RemoveTopChat -> String
show :: RemoveTopChat -> String
$cshowList :: [RemoveTopChat] -> ShowS
showList :: [RemoveTopChat] -> ShowS
Show)

instance I.ShortShow RemoveTopChat where
  shortShow :: RemoveTopChat -> String
shortShow
    RemoveTopChat
      { category :: RemoveTopChat -> Maybe TopChatCategory
category = Maybe TopChatCategory
category_
      , chat_id :: RemoveTopChat -> Maybe Int
chat_id  = Maybe Int
chat_id_
      }
        = String
"RemoveTopChat"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"category" String -> Maybe TopChatCategory -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TopChatCategory
category_
          , String
"chat_id"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          ]

instance AT.ToJSON RemoveTopChat where
  toJSON :: RemoveTopChat -> Value
toJSON
    RemoveTopChat
      { category :: RemoveTopChat -> Maybe TopChatCategory
category = Maybe TopChatCategory
category_
      , chat_id :: RemoveTopChat -> Maybe Int
chat_id  = Maybe Int
chat_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
"removeTopChat"
          , Key
"category" Key -> Maybe TopChatCategory -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe TopChatCategory
category_
          , 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_
          ]

defaultRemoveTopChat :: RemoveTopChat
defaultRemoveTopChat :: RemoveTopChat
defaultRemoveTopChat =
  RemoveTopChat
    { category :: Maybe TopChatCategory
category = Maybe TopChatCategory
forall a. Maybe a
Nothing
    , chat_id :: Maybe Int
chat_id  = Maybe Int
forall a. Maybe a
Nothing
    }