{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Telegram.Bot.API.Methods.EditChatInviteLink where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Proxy
import Data.Text
import GHC.Generics (Generic)
import Servant.API
import Servant.Client hiding (Response)

import Telegram.Bot.API.Internal.Utils
import Telegram.Bot.API.MakingRequests
import Telegram.Bot.API.Types

-- ** 'editChatInviteLink'

-- | Request parameters for 'editChatInviteLink'.
data EditChatInviteLinkRequest = EditChatInviteLinkRequest
  { EditChatInviteLinkRequest -> SomeChatId
editChatInviteLinkChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername)
  , EditChatInviteLinkRequest -> Text
editChatInviteLinkInviteLink :: Text -- ^	The invite link to edit
  , EditChatInviteLinkRequest -> Maybe Text
editChatInviteLinkName :: Maybe Text -- ^ Invite link name; 0-32 characters
  , EditChatInviteLinkRequest -> Maybe Integer
editChatInviteLinkExpireDate :: Maybe Integer -- ^ Point in time (Unix timestamp) when the link will expire
  , EditChatInviteLinkRequest -> Maybe Int
editChatInviteLinkMemberLimit :: Maybe Int -- ^ Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
  , EditChatInviteLinkRequest -> Maybe Bool
editChatInviteLinkCreatesJoinRequest :: Maybe Bool -- ^ True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
  }
  deriving forall x.
Rep EditChatInviteLinkRequest x -> EditChatInviteLinkRequest
forall x.
EditChatInviteLinkRequest -> Rep EditChatInviteLinkRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EditChatInviteLinkRequest x -> EditChatInviteLinkRequest
$cfrom :: forall x.
EditChatInviteLinkRequest -> Rep EditChatInviteLinkRequest x
Generic

instance ToJSON   EditChatInviteLinkRequest where toJSON :: EditChatInviteLinkRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON EditChatInviteLinkRequest where parseJSON :: Value -> Parser EditChatInviteLinkRequest
parseJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON

type EditChatInviteLink = "editChatInviteLink"
  :> ReqBody '[JSON] EditChatInviteLinkRequest
  :> Post '[JSON] (Response ChatInviteLink)

-- | Use this method to edit a non-primary
--   invite link created by the bot. The 
--   bot must be an administrator in the 
--   chat for this to work and must have 
--   the appropriate administrator rights.
--   Returns the edited invite link as a ChatInviteLink object.
editChatInviteLink :: EditChatInviteLinkRequest ->  ClientM (Response ChatInviteLink)
editChatInviteLink :: EditChatInviteLinkRequest -> ClientM (Response ChatInviteLink)
editChatInviteLink = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @EditChatInviteLink)