module TD.Query.DeleteAllRevokedChatInviteLinks
  (DeleteAllRevokedChatInviteLinks(..)
  , defaultDeleteAllRevokedChatInviteLinks
  ) where

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

-- | Deletes all revoked chat invite links created by a given chat administrator. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links. Returns 'TD.Data.Ok.Ok'
data DeleteAllRevokedChatInviteLinks
  = DeleteAllRevokedChatInviteLinks
    { DeleteAllRevokedChatInviteLinks -> Maybe Int
chat_id         :: Maybe Int -- ^ Chat identifier
    , DeleteAllRevokedChatInviteLinks -> Maybe Int
creator_user_id :: Maybe Int -- ^ User identifier of a chat administrator, which links will be deleted. Must be an identifier of the current user for non-owner
    }
  deriving (DeleteAllRevokedChatInviteLinks
-> DeleteAllRevokedChatInviteLinks -> Bool
(DeleteAllRevokedChatInviteLinks
 -> DeleteAllRevokedChatInviteLinks -> Bool)
-> (DeleteAllRevokedChatInviteLinks
    -> DeleteAllRevokedChatInviteLinks -> Bool)
-> Eq DeleteAllRevokedChatInviteLinks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteAllRevokedChatInviteLinks
-> DeleteAllRevokedChatInviteLinks -> Bool
== :: DeleteAllRevokedChatInviteLinks
-> DeleteAllRevokedChatInviteLinks -> Bool
$c/= :: DeleteAllRevokedChatInviteLinks
-> DeleteAllRevokedChatInviteLinks -> Bool
/= :: DeleteAllRevokedChatInviteLinks
-> DeleteAllRevokedChatInviteLinks -> Bool
Eq, Int -> DeleteAllRevokedChatInviteLinks -> ShowS
[DeleteAllRevokedChatInviteLinks] -> ShowS
DeleteAllRevokedChatInviteLinks -> String
(Int -> DeleteAllRevokedChatInviteLinks -> ShowS)
-> (DeleteAllRevokedChatInviteLinks -> String)
-> ([DeleteAllRevokedChatInviteLinks] -> ShowS)
-> Show DeleteAllRevokedChatInviteLinks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteAllRevokedChatInviteLinks -> ShowS
showsPrec :: Int -> DeleteAllRevokedChatInviteLinks -> ShowS
$cshow :: DeleteAllRevokedChatInviteLinks -> String
show :: DeleteAllRevokedChatInviteLinks -> String
$cshowList :: [DeleteAllRevokedChatInviteLinks] -> ShowS
showList :: [DeleteAllRevokedChatInviteLinks] -> ShowS
Show)

instance I.ShortShow DeleteAllRevokedChatInviteLinks where
  shortShow :: DeleteAllRevokedChatInviteLinks -> String
shortShow
    DeleteAllRevokedChatInviteLinks
      { chat_id :: DeleteAllRevokedChatInviteLinks -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , creator_user_id :: DeleteAllRevokedChatInviteLinks -> Maybe Int
creator_user_id = Maybe Int
creator_user_id_
      }
        = String
"DeleteAllRevokedChatInviteLinks"
          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
"creator_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
creator_user_id_
          ]

instance AT.ToJSON DeleteAllRevokedChatInviteLinks where
  toJSON :: DeleteAllRevokedChatInviteLinks -> Value
toJSON
    DeleteAllRevokedChatInviteLinks
      { chat_id :: DeleteAllRevokedChatInviteLinks -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , creator_user_id :: DeleteAllRevokedChatInviteLinks -> Maybe Int
creator_user_id = Maybe Int
creator_user_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
"deleteAllRevokedChatInviteLinks"
          , 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
"creator_user_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
creator_user_id_
          ]

defaultDeleteAllRevokedChatInviteLinks :: DeleteAllRevokedChatInviteLinks
defaultDeleteAllRevokedChatInviteLinks :: DeleteAllRevokedChatInviteLinks
defaultDeleteAllRevokedChatInviteLinks =
  DeleteAllRevokedChatInviteLinks
    { chat_id :: Maybe Int
chat_id         = Maybe Int
forall a. Maybe a
Nothing
    , creator_user_id :: Maybe Int
creator_user_id = Maybe Int
forall a. Maybe a
Nothing
    }