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

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Proxy
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

-- ** 'banChatMember'

-- | Request parameters for 'banChatMember'.
data BanChatMemberRequest = BanChatMemberRequest
  { BanChatMemberRequest -> SomeChatId
banChatMemberChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername)
  , BanChatMemberRequest -> UserId
banChatMemberUserId :: UserId -- ^ Unique identifier of the target user
  , BanChatMemberRequest -> Maybe Int
banChatMemberUntilDate :: Maybe Int -- ^ Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
  , BanChatMemberRequest -> Maybe Bool
banChatMemberRevokeMessages :: Maybe Bool -- ^ Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.
  }
  deriving forall x. Rep BanChatMemberRequest x -> BanChatMemberRequest
forall x. BanChatMemberRequest -> Rep BanChatMemberRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BanChatMemberRequest x -> BanChatMemberRequest
$cfrom :: forall x. BanChatMemberRequest -> Rep BanChatMemberRequest x
Generic

instance ToJSON   BanChatMemberRequest where toJSON :: BanChatMemberRequest -> 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 BanChatMemberRequest where parseJSON :: Value -> Parser BanChatMemberRequest
parseJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON

type BanChatMember = "banChatMember"
  :> ReqBody '[JSON] BanChatMemberRequest
  :> Post '[JSON] (Response Bool)

-- | Use this method to ban a user in a
--   group, a supergroup or a channel.
--   In the case of supergroups and channels,
--   the user will not be able to return to
--   the chat on their own using invite links,
--   etc., unless unbanned first. The bot must
--   be an administrator in the chat for this
--   to work and must have the appropriate
--   administrator rights.
--   Returns True on success.
banChatMember :: BanChatMemberRequest ->  ClientM (Response Bool)
banChatMember :: BanChatMemberRequest -> ClientM (Response Bool)
banChatMember = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @BanChatMember)