module TD.Query.GetChatJoinRequests
  (GetChatJoinRequests(..)
  , defaultGetChatJoinRequests
  ) 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
import qualified TD.Data.ChatJoinRequest as ChatJoinRequest

-- | Returns pending join requests in a chat. Returns 'TD.Data.ChatJoinRequests.ChatJoinRequests'
data GetChatJoinRequests
  = GetChatJoinRequests
    { GetChatJoinRequests -> Maybe Int
chat_id        :: Maybe Int                             -- ^ Chat identifier
    , GetChatJoinRequests -> Maybe Text
invite_link    :: Maybe T.Text                          -- ^ Invite link for which to return join requests. If empty, all join requests will be returned. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
    , GetChatJoinRequests -> Maybe Text
query          :: Maybe T.Text                          -- ^ A query to search for in the first names, last names and usernames of the users to return
    , GetChatJoinRequests -> Maybe ChatJoinRequest
offset_request :: Maybe ChatJoinRequest.ChatJoinRequest -- ^ A chat join request from which to return next requests; pass null to get results from the beginning
    , GetChatJoinRequests -> Maybe Int
limit          :: Maybe Int                             -- ^ The maximum number of requests to join the chat to return
    }
  deriving (GetChatJoinRequests -> GetChatJoinRequests -> Bool
(GetChatJoinRequests -> GetChatJoinRequests -> Bool)
-> (GetChatJoinRequests -> GetChatJoinRequests -> Bool)
-> Eq GetChatJoinRequests
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatJoinRequests -> GetChatJoinRequests -> Bool
== :: GetChatJoinRequests -> GetChatJoinRequests -> Bool
$c/= :: GetChatJoinRequests -> GetChatJoinRequests -> Bool
/= :: GetChatJoinRequests -> GetChatJoinRequests -> Bool
Eq, Int -> GetChatJoinRequests -> ShowS
[GetChatJoinRequests] -> ShowS
GetChatJoinRequests -> String
(Int -> GetChatJoinRequests -> ShowS)
-> (GetChatJoinRequests -> String)
-> ([GetChatJoinRequests] -> ShowS)
-> Show GetChatJoinRequests
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatJoinRequests -> ShowS
showsPrec :: Int -> GetChatJoinRequests -> ShowS
$cshow :: GetChatJoinRequests -> String
show :: GetChatJoinRequests -> String
$cshowList :: [GetChatJoinRequests] -> ShowS
showList :: [GetChatJoinRequests] -> ShowS
Show)

instance I.ShortShow GetChatJoinRequests where
  shortShow :: GetChatJoinRequests -> String
shortShow
    GetChatJoinRequests
      { chat_id :: GetChatJoinRequests -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , invite_link :: GetChatJoinRequests -> Maybe Text
invite_link    = Maybe Text
invite_link_
      , query :: GetChatJoinRequests -> Maybe Text
query          = Maybe Text
query_
      , offset_request :: GetChatJoinRequests -> Maybe ChatJoinRequest
offset_request = Maybe ChatJoinRequest
offset_request_
      , limit :: GetChatJoinRequests -> Maybe Int
limit          = Maybe Int
limit_
      }
        = String
"GetChatJoinRequests"
          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_
          , String
"query"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
          , String
"offset_request" String -> Maybe ChatJoinRequest -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatJoinRequest
offset_request_
          , String
"limit"          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChatJoinRequests where
  toJSON :: GetChatJoinRequests -> Value
toJSON
    GetChatJoinRequests
      { chat_id :: GetChatJoinRequests -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , invite_link :: GetChatJoinRequests -> Maybe Text
invite_link    = Maybe Text
invite_link_
      , query :: GetChatJoinRequests -> Maybe Text
query          = Maybe Text
query_
      , offset_request :: GetChatJoinRequests -> Maybe ChatJoinRequest
offset_request = Maybe ChatJoinRequest
offset_request_
      , limit :: GetChatJoinRequests -> 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
"getChatJoinRequests"
          , 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_
          , Key
"query"          Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
          , Key
"offset_request" Key -> Maybe ChatJoinRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatJoinRequest
offset_request_
          , 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_
          ]

defaultGetChatJoinRequests :: GetChatJoinRequests
defaultGetChatJoinRequests :: GetChatJoinRequests
defaultGetChatJoinRequests =
  GetChatJoinRequests
    { 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
    , query :: Maybe Text
query          = Maybe Text
forall a. Maybe a
Nothing
    , offset_request :: Maybe ChatJoinRequest
offset_request = Maybe ChatJoinRequest
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit          = Maybe Int
forall a. Maybe a
Nothing
    }