module TD.Query.DeleteChatHistory
  (DeleteChatHistory(..)
  , defaultDeleteChatHistory
  ) where

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

-- | Deletes all messages in the chat. Use chat.can_be_deleted_only_for_self and chat.can_be_deleted_for_all_users fields to find whether and how the method can be applied to the chat. Returns 'TD.Data.Ok.Ok'
data DeleteChatHistory
  = DeleteChatHistory
    { DeleteChatHistory -> Maybe Int
chat_id               :: Maybe Int  -- ^ Chat identifier
    , DeleteChatHistory -> Maybe Bool
remove_from_chat_list :: Maybe Bool -- ^ Pass true to remove the chat from all chat lists
    , DeleteChatHistory -> Maybe Bool
revoke                :: Maybe Bool -- ^ Pass true to delete chat history for all users
    }
  deriving (DeleteChatHistory -> DeleteChatHistory -> Bool
(DeleteChatHistory -> DeleteChatHistory -> Bool)
-> (DeleteChatHistory -> DeleteChatHistory -> Bool)
-> Eq DeleteChatHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteChatHistory -> DeleteChatHistory -> Bool
== :: DeleteChatHistory -> DeleteChatHistory -> Bool
$c/= :: DeleteChatHistory -> DeleteChatHistory -> Bool
/= :: DeleteChatHistory -> DeleteChatHistory -> Bool
Eq, Int -> DeleteChatHistory -> ShowS
[DeleteChatHistory] -> ShowS
DeleteChatHistory -> String
(Int -> DeleteChatHistory -> ShowS)
-> (DeleteChatHistory -> String)
-> ([DeleteChatHistory] -> ShowS)
-> Show DeleteChatHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteChatHistory -> ShowS
showsPrec :: Int -> DeleteChatHistory -> ShowS
$cshow :: DeleteChatHistory -> String
show :: DeleteChatHistory -> String
$cshowList :: [DeleteChatHistory] -> ShowS
showList :: [DeleteChatHistory] -> ShowS
Show)

instance I.ShortShow DeleteChatHistory where
  shortShow :: DeleteChatHistory -> String
shortShow
    DeleteChatHistory
      { chat_id :: DeleteChatHistory -> Maybe Int
chat_id               = Maybe Int
chat_id_
      , remove_from_chat_list :: DeleteChatHistory -> Maybe Bool
remove_from_chat_list = Maybe Bool
remove_from_chat_list_
      , revoke :: DeleteChatHistory -> Maybe Bool
revoke                = Maybe Bool
revoke_
      }
        = String
"DeleteChatHistory"
          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
"remove_from_chat_list" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
remove_from_chat_list_
          , String
"revoke"                String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
revoke_
          ]

instance AT.ToJSON DeleteChatHistory where
  toJSON :: DeleteChatHistory -> Value
toJSON
    DeleteChatHistory
      { chat_id :: DeleteChatHistory -> Maybe Int
chat_id               = Maybe Int
chat_id_
      , remove_from_chat_list :: DeleteChatHistory -> Maybe Bool
remove_from_chat_list = Maybe Bool
remove_from_chat_list_
      , revoke :: DeleteChatHistory -> Maybe Bool
revoke                = Maybe Bool
revoke_
      }
        = [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
"deleteChatHistory"
          , 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
"remove_from_chat_list" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
remove_from_chat_list_
          , Key
"revoke"                Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
revoke_
          ]

defaultDeleteChatHistory :: DeleteChatHistory
defaultDeleteChatHistory :: DeleteChatHistory
defaultDeleteChatHistory =
  DeleteChatHistory
    { chat_id :: Maybe Int
chat_id               = Maybe Int
forall a. Maybe a
Nothing
    , remove_from_chat_list :: Maybe Bool
remove_from_chat_list = Maybe Bool
forall a. Maybe a
Nothing
    , revoke :: Maybe Bool
revoke                = Maybe Bool
forall a. Maybe a
Nothing
    }