module TD.Query.CloseChat
  (CloseChat(..)
  ) where

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

-- | Informs TDLib that the chat is closed by the user. Many useful activities depend on the chat being opened or closed. Returns 'TD.Data.Ok.Ok'
data CloseChat
  = CloseChat
    { CloseChat -> Maybe Int
chat_id :: Maybe Int -- ^ Chat identifier
    }
  deriving (CloseChat -> CloseChat -> Bool
(CloseChat -> CloseChat -> Bool)
-> (CloseChat -> CloseChat -> Bool) -> Eq CloseChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CloseChat -> CloseChat -> Bool
== :: CloseChat -> CloseChat -> Bool
$c/= :: CloseChat -> CloseChat -> Bool
/= :: CloseChat -> CloseChat -> Bool
Eq, Int -> CloseChat -> ShowS
[CloseChat] -> ShowS
CloseChat -> String
(Int -> CloseChat -> ShowS)
-> (CloseChat -> String)
-> ([CloseChat] -> ShowS)
-> Show CloseChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CloseChat -> ShowS
showsPrec :: Int -> CloseChat -> ShowS
$cshow :: CloseChat -> String
show :: CloseChat -> String
$cshowList :: [CloseChat] -> ShowS
showList :: [CloseChat] -> ShowS
Show)

instance I.ShortShow CloseChat where
  shortShow :: CloseChat -> String
shortShow
    CloseChat
      { chat_id :: CloseChat -> Maybe Int
chat_id = Maybe Int
chat_id_
      }
        = String
"CloseChat"
          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_
          ]

instance AT.ToJSON CloseChat where
  toJSON :: CloseChat -> Value
toJSON
    CloseChat
      { chat_id :: CloseChat -> 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
"closeChat"
          , 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_
          ]