module TD.Query.CloseSecretChat
  (CloseSecretChat(..)
  ) where

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

-- | Closes a secret chat, effectively transferring its state to secretChatStateClosed. Returns 'TD.Data.Ok.Ok'
data CloseSecretChat
  = CloseSecretChat
    { CloseSecretChat -> Maybe Int
secret_chat_id :: Maybe Int -- ^ Secret chat identifier
    }
  deriving (CloseSecretChat -> CloseSecretChat -> Bool
(CloseSecretChat -> CloseSecretChat -> Bool)
-> (CloseSecretChat -> CloseSecretChat -> Bool)
-> Eq CloseSecretChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CloseSecretChat -> CloseSecretChat -> Bool
== :: CloseSecretChat -> CloseSecretChat -> Bool
$c/= :: CloseSecretChat -> CloseSecretChat -> Bool
/= :: CloseSecretChat -> CloseSecretChat -> Bool
Eq, Int -> CloseSecretChat -> ShowS
[CloseSecretChat] -> ShowS
CloseSecretChat -> String
(Int -> CloseSecretChat -> ShowS)
-> (CloseSecretChat -> String)
-> ([CloseSecretChat] -> ShowS)
-> Show CloseSecretChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CloseSecretChat -> ShowS
showsPrec :: Int -> CloseSecretChat -> ShowS
$cshow :: CloseSecretChat -> String
show :: CloseSecretChat -> String
$cshowList :: [CloseSecretChat] -> ShowS
showList :: [CloseSecretChat] -> ShowS
Show)

instance I.ShortShow CloseSecretChat where
  shortShow :: CloseSecretChat -> String
shortShow
    CloseSecretChat
      { secret_chat_id :: CloseSecretChat -> Maybe Int
secret_chat_id = Maybe Int
secret_chat_id_
      }
        = String
"CloseSecretChat"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"secret_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
secret_chat_id_
          ]

instance AT.ToJSON CloseSecretChat where
  toJSON :: CloseSecretChat -> Value
toJSON
    CloseSecretChat
      { secret_chat_id :: CloseSecretChat -> Maybe Int
secret_chat_id = Maybe Int
secret_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
"closeSecretChat"
          , Key
"secret_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
secret_chat_id_
          ]