module TD.Query.GetChatInviteLinkMembers
  (GetChatInviteLinkMembers(..)
  , defaultGetChatInviteLinkMembers
  ) 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.ChatInviteLinkMember as ChatInviteLinkMember

-- | Returns chat members joined a chat via an invite link. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links. Returns 'TD.Data.ChatInviteLinkMembers.ChatInviteLinkMembers'
data GetChatInviteLinkMembers
  = GetChatInviteLinkMembers
    { GetChatInviteLinkMembers -> Maybe Int
chat_id                        :: Maybe Int                                       -- ^ Chat identifier
    , GetChatInviteLinkMembers -> Maybe Text
invite_link                    :: Maybe T.Text                                    -- ^ Invite link for which to return chat members
    , GetChatInviteLinkMembers -> Maybe Bool
only_with_expired_subscription :: Maybe Bool                                      -- ^ Pass true if the link is a subscription link and only members with expired subscription must be returned
    , GetChatInviteLinkMembers -> Maybe ChatInviteLinkMember
offset_member                  :: Maybe ChatInviteLinkMember.ChatInviteLinkMember -- ^ A chat member from which to return next chat members; pass null to get results from the beginning
    , GetChatInviteLinkMembers -> Maybe Int
limit                          :: Maybe Int                                       -- ^ The maximum number of chat members to return; up to 100
    }
  deriving (GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool
(GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool)
-> (GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool)
-> Eq GetChatInviteLinkMembers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool
== :: GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool
$c/= :: GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool
/= :: GetChatInviteLinkMembers -> GetChatInviteLinkMembers -> Bool
Eq, Int -> GetChatInviteLinkMembers -> ShowS
[GetChatInviteLinkMembers] -> ShowS
GetChatInviteLinkMembers -> String
(Int -> GetChatInviteLinkMembers -> ShowS)
-> (GetChatInviteLinkMembers -> String)
-> ([GetChatInviteLinkMembers] -> ShowS)
-> Show GetChatInviteLinkMembers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatInviteLinkMembers -> ShowS
showsPrec :: Int -> GetChatInviteLinkMembers -> ShowS
$cshow :: GetChatInviteLinkMembers -> String
show :: GetChatInviteLinkMembers -> String
$cshowList :: [GetChatInviteLinkMembers] -> ShowS
showList :: [GetChatInviteLinkMembers] -> ShowS
Show)

instance I.ShortShow GetChatInviteLinkMembers where
  shortShow :: GetChatInviteLinkMembers -> String
shortShow
    GetChatInviteLinkMembers
      { chat_id :: GetChatInviteLinkMembers -> Maybe Int
chat_id                        = Maybe Int
chat_id_
      , invite_link :: GetChatInviteLinkMembers -> Maybe Text
invite_link                    = Maybe Text
invite_link_
      , only_with_expired_subscription :: GetChatInviteLinkMembers -> Maybe Bool
only_with_expired_subscription = Maybe Bool
only_with_expired_subscription_
      , offset_member :: GetChatInviteLinkMembers -> Maybe ChatInviteLinkMember
offset_member                  = Maybe ChatInviteLinkMember
offset_member_
      , limit :: GetChatInviteLinkMembers -> Maybe Int
limit                          = Maybe Int
limit_
      }
        = String
"GetChatInviteLinkMembers"
          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
"only_with_expired_subscription" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_with_expired_subscription_
          , String
"offset_member"                  String -> Maybe ChatInviteLinkMember -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatInviteLinkMember
offset_member_
          , String
"limit"                          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChatInviteLinkMembers where
  toJSON :: GetChatInviteLinkMembers -> Value
toJSON
    GetChatInviteLinkMembers
      { chat_id :: GetChatInviteLinkMembers -> Maybe Int
chat_id                        = Maybe Int
chat_id_
      , invite_link :: GetChatInviteLinkMembers -> Maybe Text
invite_link                    = Maybe Text
invite_link_
      , only_with_expired_subscription :: GetChatInviteLinkMembers -> Maybe Bool
only_with_expired_subscription = Maybe Bool
only_with_expired_subscription_
      , offset_member :: GetChatInviteLinkMembers -> Maybe ChatInviteLinkMember
offset_member                  = Maybe ChatInviteLinkMember
offset_member_
      , limit :: GetChatInviteLinkMembers -> 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
"getChatInviteLinkMembers"
          , 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
"only_with_expired_subscription" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_with_expired_subscription_
          , Key
"offset_member"                  Key -> Maybe ChatInviteLinkMember -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatInviteLinkMember
offset_member_
          , 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_
          ]

defaultGetChatInviteLinkMembers :: GetChatInviteLinkMembers
defaultGetChatInviteLinkMembers :: GetChatInviteLinkMembers
defaultGetChatInviteLinkMembers =
  GetChatInviteLinkMembers
    { 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
    , only_with_expired_subscription :: Maybe Bool
only_with_expired_subscription = Maybe Bool
forall a. Maybe a
Nothing
    , offset_member :: Maybe ChatInviteLinkMember
offset_member                  = Maybe ChatInviteLinkMember
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit                          = Maybe Int
forall a. Maybe a
Nothing
    }