module Web.Telegram.API.Bot.API.Chats
(
kickChatMember
, kickChatMemberM
, leaveChat
, leaveChatM
, unbanChatMember
, unbanChatMemberM
, getChat
, getChatM
, getChatAdministrators
, getChatAdministratorsM
, getChatMembersCount
, getChatMembersCountM
, getChatMember
, getChatMemberM
, TelegramBotChatsAPI
, chatsApi
) where
import Data.Proxy
import Data.Text (Text)
import Network.HTTP.Client (Manager)
import Servant.API
import Servant.Client
import Web.Telegram.API.Bot.API.Core
import Web.Telegram.API.Bot.Responses
type TelegramBotChatsAPI =
TelegramToken :> "kickChatMember"
:> QueryParam "chat_id" Text
:> QueryParam "user_id" Int
:> Post '[JSON] KickChatMemberResponse
:<|> TelegramToken :> "leaveChat"
:> QueryParam "chat_id" Text
:> Post '[JSON] LeaveChatResponse
:<|> TelegramToken :> "unbanChatMember"
:> QueryParam "chat_id" Text
:> QueryParam "user_id" Int
:> Post '[JSON] UnbanChatMemberResponse
:<|> TelegramToken :> "getChat"
:> QueryParam "chat_id" Text
:> Post '[JSON] GetChatResponse
:<|> TelegramToken :> "getChatAdministrators"
:> QueryParam "chat_id" Text
:> Post '[JSON] GetChatAdministratorsResponse
:<|> TelegramToken :> "getChatMembersCount"
:> QueryParam "chat_id" Text
:> Post '[JSON] GetChatMembersCountResponse
:<|> TelegramToken :> "getChatMember"
:> QueryParam "chat_id" Text
:> QueryParam "user_id" Int
:> Post '[JSON] GetChatMemberResponse
chatsApi :: Proxy TelegramBotChatsAPI
chatsApi = Proxy
kickChatMember_ :: Token -> Maybe Text -> Maybe Int -> ClientM KickChatMemberResponse
leaveChat_ :: Token -> Maybe Text -> ClientM LeaveChatResponse
unbanChatMember_ :: Token -> Maybe Text -> Maybe Int -> ClientM UnbanChatMemberResponse
getChat_ :: Token -> Maybe Text -> ClientM GetChatResponse
getChatAdministrators_ :: Token -> Maybe Text -> ClientM GetChatAdministratorsResponse
getChatMembersCount_ :: Token -> Maybe Text -> ClientM GetChatMembersCountResponse
getChatMember_ :: Token -> Maybe Text -> Maybe Int -> ClientM GetChatMemberResponse
kickChatMember_
:<|> leaveChat_
:<|> unbanChatMember_
:<|> getChat_
:<|> getChatAdministrators_
:<|> getChatMembersCount_
:<|> getChatMember_ = client chatsApi
kickChatMember :: Token -> Text -> Int -> Manager -> IO (Either ServantError KickChatMemberResponse)
kickChatMember token chatId userId = runClient (kickChatMemberM chatId userId) token
kickChatMemberM :: Text -> Int -> TelegramClient KickChatMemberResponse
kickChatMemberM chatId userId = asking $ \t -> kickChatMember_ t (Just chatId) (Just userId)
leaveChat :: Token -> Text -> Manager -> IO (Either ServantError LeaveChatResponse)
leaveChat = runM leaveChatM
leaveChatM :: Text -> TelegramClient LeaveChatResponse
leaveChatM chatId = run_ leaveChat_ (Just chatId)
unbanChatMember :: Token -> Text -> Int -> Manager -> IO (Either ServantError UnbanChatMemberResponse)
unbanChatMember token chatId userId = runClient (unbanChatMemberM chatId userId) token
unbanChatMemberM :: Text -> Int -> TelegramClient UnbanChatMemberResponse
unbanChatMemberM chatId userId = asking $ \t -> unbanChatMember_ t (Just chatId) (Just userId)
getChat :: Token -> Text -> Manager -> IO (Either ServantError GetChatResponse)
getChat = runM getChatM
getChatM :: Text -> TelegramClient GetChatResponse
getChatM chatId = run_ getChat_ (Just chatId)
getChatAdministrators :: Token -> Text -> Manager -> IO (Either ServantError GetChatAdministratorsResponse)
getChatAdministrators = runM getChatAdministratorsM
getChatAdministratorsM :: Text -> TelegramClient GetChatAdministratorsResponse
getChatAdministratorsM chatId = run_ getChatAdministrators_ (Just chatId)
getChatMembersCount :: Token -> Text -> Manager -> IO (Either ServantError GetChatMembersCountResponse)
getChatMembersCount = runM getChatMembersCountM
getChatMembersCountM :: Text -> TelegramClient GetChatMembersCountResponse
getChatMembersCountM chatId = run_ getChatMembersCount_ (Just chatId)
getChatMember :: Token -> Text -> Int -> Manager -> IO (Either ServantError GetChatMemberResponse)
getChatMember token chatId userId = runClient (getChatMemberM chatId userId) token
getChatMemberM :: Text -> Int -> TelegramClient GetChatMemberResponse
getChatMemberM chatId userId = asking $ \t -> getChatMember_ t (Just chatId) (Just userId)