module TD.Query.GetChatInviteLinks
  (GetChatInviteLinks(..)
  , defaultGetChatInviteLinks
  ) 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

-- | Returns invite links for a chat created by specified administrator. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links. Returns 'TD.Data.ChatInviteLinks.ChatInviteLinks'
data GetChatInviteLinks
  = GetChatInviteLinks
    { GetChatInviteLinks -> Maybe Int
chat_id            :: Maybe Int    -- ^ Chat identifier
    , GetChatInviteLinks -> Maybe Int
creator_user_id    :: Maybe Int    -- ^ User identifier of a chat administrator. Must be an identifier of the current user for non-owner
    , GetChatInviteLinks -> Maybe Bool
is_revoked         :: Maybe Bool   -- ^ Pass true if revoked links needs to be returned instead of active or expired
    , GetChatInviteLinks -> Maybe Int
offset_date        :: Maybe Int    -- ^ Creation date of an invite link starting after which to return invite links; use 0 to get results from the beginning
    , GetChatInviteLinks -> Maybe Text
offset_invite_link :: Maybe T.Text -- ^ Invite link starting after which to return invite links; use empty string to get results from the beginning
    , GetChatInviteLinks -> Maybe Int
limit              :: Maybe Int    -- ^ The maximum number of invite links to return; up to 100
    }
  deriving (GetChatInviteLinks -> GetChatInviteLinks -> Bool
(GetChatInviteLinks -> GetChatInviteLinks -> Bool)
-> (GetChatInviteLinks -> GetChatInviteLinks -> Bool)
-> Eq GetChatInviteLinks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatInviteLinks -> GetChatInviteLinks -> Bool
== :: GetChatInviteLinks -> GetChatInviteLinks -> Bool
$c/= :: GetChatInviteLinks -> GetChatInviteLinks -> Bool
/= :: GetChatInviteLinks -> GetChatInviteLinks -> Bool
Eq, Int -> GetChatInviteLinks -> ShowS
[GetChatInviteLinks] -> ShowS
GetChatInviteLinks -> String
(Int -> GetChatInviteLinks -> ShowS)
-> (GetChatInviteLinks -> String)
-> ([GetChatInviteLinks] -> ShowS)
-> Show GetChatInviteLinks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatInviteLinks -> ShowS
showsPrec :: Int -> GetChatInviteLinks -> ShowS
$cshow :: GetChatInviteLinks -> String
show :: GetChatInviteLinks -> String
$cshowList :: [GetChatInviteLinks] -> ShowS
showList :: [GetChatInviteLinks] -> ShowS
Show)

instance I.ShortShow GetChatInviteLinks where
  shortShow :: GetChatInviteLinks -> String
shortShow
    GetChatInviteLinks
      { chat_id :: GetChatInviteLinks -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , creator_user_id :: GetChatInviteLinks -> Maybe Int
creator_user_id    = Maybe Int
creator_user_id_
      , is_revoked :: GetChatInviteLinks -> Maybe Bool
is_revoked         = Maybe Bool
is_revoked_
      , offset_date :: GetChatInviteLinks -> Maybe Int
offset_date        = Maybe Int
offset_date_
      , offset_invite_link :: GetChatInviteLinks -> Maybe Text
offset_invite_link = Maybe Text
offset_invite_link_
      , limit :: GetChatInviteLinks -> Maybe Int
limit              = Maybe Int
limit_
      }
        = String
"GetChatInviteLinks"
          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_
          , String
"is_revoked"         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_revoked_
          , String
"offset_date"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_date_
          , String
"offset_invite_link" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_invite_link_
          , String
"limit"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChatInviteLinks where
  toJSON :: GetChatInviteLinks -> Value
toJSON
    GetChatInviteLinks
      { chat_id :: GetChatInviteLinks -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , creator_user_id :: GetChatInviteLinks -> Maybe Int
creator_user_id    = Maybe Int
creator_user_id_
      , is_revoked :: GetChatInviteLinks -> Maybe Bool
is_revoked         = Maybe Bool
is_revoked_
      , offset_date :: GetChatInviteLinks -> Maybe Int
offset_date        = Maybe Int
offset_date_
      , offset_invite_link :: GetChatInviteLinks -> Maybe Text
offset_invite_link = Maybe Text
offset_invite_link_
      , limit :: GetChatInviteLinks -> Maybe Int
limit              = Maybe Int
limit_
      }
        = [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
"getChatInviteLinks"
          , 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_
          , Key
"is_revoked"         Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_revoked_
          , Key
"offset_date"        Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
offset_date_
          , Key
"offset_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
offset_invite_link_
          , Key
"limit"              Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetChatInviteLinks :: GetChatInviteLinks
defaultGetChatInviteLinks :: GetChatInviteLinks
defaultGetChatInviteLinks =
  GetChatInviteLinks
    { 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
    , is_revoked :: Maybe Bool
is_revoked         = Maybe Bool
forall a. Maybe a
Nothing
    , offset_date :: Maybe Int
offset_date        = Maybe Int
forall a. Maybe a
Nothing
    , offset_invite_link :: Maybe Text
offset_invite_link = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit              = Maybe Int
forall a. Maybe a
Nothing
    }