module TD.Query.RevokeChatInviteLink
  (RevokeChatInviteLink(..)
  , defaultRevokeChatInviteLink
  ) where

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

-- | Revokes invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links. If a primary link is revoked, then additionally to the revoked link returns new primary link. Returns 'TD.Data.ChatInviteLinks.ChatInviteLinks'
data RevokeChatInviteLink
  = RevokeChatInviteLink
    { RevokeChatInviteLink -> Maybe Int
chat_id     :: Maybe Int    -- ^ Chat identifier
    , RevokeChatInviteLink -> Maybe Text
invite_link :: Maybe T.Text -- ^ Invite link to be revoked
    }
  deriving (RevokeChatInviteLink -> RevokeChatInviteLink -> Bool
(RevokeChatInviteLink -> RevokeChatInviteLink -> Bool)
-> (RevokeChatInviteLink -> RevokeChatInviteLink -> Bool)
-> Eq RevokeChatInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RevokeChatInviteLink -> RevokeChatInviteLink -> Bool
== :: RevokeChatInviteLink -> RevokeChatInviteLink -> Bool
$c/= :: RevokeChatInviteLink -> RevokeChatInviteLink -> Bool
/= :: RevokeChatInviteLink -> RevokeChatInviteLink -> Bool
Eq, Int -> RevokeChatInviteLink -> ShowS
[RevokeChatInviteLink] -> ShowS
RevokeChatInviteLink -> String
(Int -> RevokeChatInviteLink -> ShowS)
-> (RevokeChatInviteLink -> String)
-> ([RevokeChatInviteLink] -> ShowS)
-> Show RevokeChatInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RevokeChatInviteLink -> ShowS
showsPrec :: Int -> RevokeChatInviteLink -> ShowS
$cshow :: RevokeChatInviteLink -> String
show :: RevokeChatInviteLink -> String
$cshowList :: [RevokeChatInviteLink] -> ShowS
showList :: [RevokeChatInviteLink] -> ShowS
Show)

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

instance AT.ToJSON RevokeChatInviteLink where
  toJSON :: RevokeChatInviteLink -> Value
toJSON
    RevokeChatInviteLink
      { chat_id :: RevokeChatInviteLink -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , invite_link :: RevokeChatInviteLink -> Maybe Text
invite_link = Maybe Text
invite_link_
      }
        = [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
"revokeChatInviteLink"
          , 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
"invite_link" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
invite_link_
          ]

defaultRevokeChatInviteLink :: RevokeChatInviteLink
defaultRevokeChatInviteLink :: RevokeChatInviteLink
defaultRevokeChatInviteLink =
  RevokeChatInviteLink
    { chat_id :: Maybe Int
chat_id     = Maybe Int
forall a. Maybe a
Nothing
    , invite_link :: Maybe Text
invite_link = Maybe Text
forall a. Maybe a
Nothing
    }