module TD.Query.EditChatInviteLink
  (EditChatInviteLink(..)
  , defaultEditChatInviteLink
  ) 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

-- | Edits a non-primary invite link for a chat. Available for basic groups, supergroups, and channels. If the link creates a subscription, then expiration_date, member_limit and creates_join_request must not be used. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links. Returns 'TD.Data.ChatInviteLink.ChatInviteLink'
data EditChatInviteLink
  = EditChatInviteLink
    { EditChatInviteLink -> Maybe Int
chat_id              :: Maybe Int    -- ^ Chat identifier
    , EditChatInviteLink -> Maybe Text
invite_link          :: Maybe T.Text -- ^ Invite link to be edited
    , EditChatInviteLink -> Maybe Text
name                 :: Maybe T.Text -- ^ Invite link name; 0-32 characters
    , EditChatInviteLink -> Maybe Int
expiration_date      :: Maybe Int    -- ^ Point in time (Unix timestamp) when the link will expire; pass 0 if never
    , EditChatInviteLink -> Maybe Int
member_limit         :: Maybe Int    -- ^ The maximum number of chat members that can join the chat via the link simultaneously; 0-99999; pass 0 if not limited
    , EditChatInviteLink -> Maybe Bool
creates_join_request :: Maybe Bool   -- ^ Pass true if users joining the chat via the link need to be approved by chat administrators. In this case, member_limit must be 0
    }
  deriving (EditChatInviteLink -> EditChatInviteLink -> Bool
(EditChatInviteLink -> EditChatInviteLink -> Bool)
-> (EditChatInviteLink -> EditChatInviteLink -> Bool)
-> Eq EditChatInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditChatInviteLink -> EditChatInviteLink -> Bool
== :: EditChatInviteLink -> EditChatInviteLink -> Bool
$c/= :: EditChatInviteLink -> EditChatInviteLink -> Bool
/= :: EditChatInviteLink -> EditChatInviteLink -> Bool
Eq, Int -> EditChatInviteLink -> ShowS
[EditChatInviteLink] -> ShowS
EditChatInviteLink -> String
(Int -> EditChatInviteLink -> ShowS)
-> (EditChatInviteLink -> String)
-> ([EditChatInviteLink] -> ShowS)
-> Show EditChatInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditChatInviteLink -> ShowS
showsPrec :: Int -> EditChatInviteLink -> ShowS
$cshow :: EditChatInviteLink -> String
show :: EditChatInviteLink -> String
$cshowList :: [EditChatInviteLink] -> ShowS
showList :: [EditChatInviteLink] -> ShowS
Show)

instance I.ShortShow EditChatInviteLink where
  shortShow :: EditChatInviteLink -> String
shortShow
    EditChatInviteLink
      { chat_id :: EditChatInviteLink -> Maybe Int
chat_id              = Maybe Int
chat_id_
      , invite_link :: EditChatInviteLink -> Maybe Text
invite_link          = Maybe Text
invite_link_
      , name :: EditChatInviteLink -> Maybe Text
name                 = Maybe Text
name_
      , expiration_date :: EditChatInviteLink -> Maybe Int
expiration_date      = Maybe Int
expiration_date_
      , member_limit :: EditChatInviteLink -> Maybe Int
member_limit         = Maybe Int
member_limit_
      , creates_join_request :: EditChatInviteLink -> Maybe Bool
creates_join_request = Maybe Bool
creates_join_request_
      }
        = String
"EditChatInviteLink"
          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
"name"                 String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"expiration_date"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
expiration_date_
          , String
"member_limit"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
member_limit_
          , String
"creates_join_request" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
creates_join_request_
          ]

instance AT.ToJSON EditChatInviteLink where
  toJSON :: EditChatInviteLink -> Value
toJSON
    EditChatInviteLink
      { chat_id :: EditChatInviteLink -> Maybe Int
chat_id              = Maybe Int
chat_id_
      , invite_link :: EditChatInviteLink -> Maybe Text
invite_link          = Maybe Text
invite_link_
      , name :: EditChatInviteLink -> Maybe Text
name                 = Maybe Text
name_
      , expiration_date :: EditChatInviteLink -> Maybe Int
expiration_date      = Maybe Int
expiration_date_
      , member_limit :: EditChatInviteLink -> Maybe Int
member_limit         = Maybe Int
member_limit_
      , creates_join_request :: EditChatInviteLink -> Maybe Bool
creates_join_request = Maybe Bool
creates_join_request_
      }
        = [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
"editChatInviteLink"
          , 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
"name"                 Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
          , Key
"expiration_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
expiration_date_
          , Key
"member_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
member_limit_
          , Key
"creates_join_request" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
creates_join_request_
          ]

defaultEditChatInviteLink :: EditChatInviteLink
defaultEditChatInviteLink :: EditChatInviteLink
defaultEditChatInviteLink =
  EditChatInviteLink
    { 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
    , name :: Maybe Text
name                 = Maybe Text
forall a. Maybe a
Nothing
    , expiration_date :: Maybe Int
expiration_date      = Maybe Int
forall a. Maybe a
Nothing
    , member_limit :: Maybe Int
member_limit         = Maybe Int
forall a. Maybe a
Nothing
    , creates_join_request :: Maybe Bool
creates_join_request = Maybe Bool
forall a. Maybe a
Nothing
    }