module Web.Telegram.API.Bot.API
(
getMe
, sendMessage
, forwardMessage
, uploadPhoto
, sendPhoto
, uploadAudio
, sendAudio
, uploadDocument
, sendDocument
, uploadSticker
, sendSticker
, uploadVideo
, sendVideo
, uploadVoice
, sendVoice
, sendLocation
, sendVenue
, sendContact
, sendChatAction
, getUpdates
, getFile
, getUserProfilePhotos
, setWebhook
, answerInlineQuery
, answerCallbackQuery
, kickChatMember
, leaveChat
, unbanChatMember
, getChat
, getChatAdministrators
, getChatMembersCount
, getChatMember
, editMessageText
, editMessageCaption
, editMessageReplyMarkup
, TelegramBotAPI
, api
, Token (..)
) where
import Control.Monad.Trans.Except (ExceptT, runExceptT)
import Data.Proxy
import Data.Text (Text)
import Network.HTTP.Client (Manager)
import Servant.API
import Servant.Client
import Servant.Client.MultipartFormData
import Web.Telegram.API.Bot.Responses
import Web.Telegram.API.Bot.Requests
newtype Token = Token Text
deriving (Show, Eq, Ord, ToHttpApiData, FromHttpApiData)
telegramBaseUrl :: BaseUrl
telegramBaseUrl = BaseUrl Https "api.telegram.org" 443 ""
type TelegramToken = Capture ":token" Token
type TelegramBotAPI =
TelegramToken :> "getMe"
:> Get '[JSON] GetMeResponse
:<|> TelegramToken :> "sendMessage"
:> ReqBody '[JSON] SendMessageRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "forwardMessage"
:> ReqBody '[JSON] ForwardMessageRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendPhoto"
:> MultipartFormDataReqBody (SendPhotoRequest FileUpload)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendPhoto"
:> ReqBody '[JSON] (SendPhotoRequest Text)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendAudio"
:> MultipartFormDataReqBody (SendAudioRequest FileUpload)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendAudio"
:> ReqBody '[JSON] (SendAudioRequest Text)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendDocument"
:> MultipartFormDataReqBody (SendDocumentRequest FileUpload)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendDocument"
:> ReqBody '[JSON] (SendDocumentRequest Text)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendSticker"
:> MultipartFormDataReqBody (SendStickerRequest FileUpload)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendSticker"
:> ReqBody '[JSON] (SendStickerRequest Text)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendVideo"
:> MultipartFormDataReqBody (SendVideoRequest FileUpload)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendVideo"
:> ReqBody '[JSON] (SendVideoRequest Text)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendVoice"
:> MultipartFormDataReqBody (SendVoiceRequest FileUpload)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendVoice"
:> ReqBody '[JSON] (SendVoiceRequest Text)
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendLocation"
:> ReqBody '[JSON] SendLocationRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendVenue"
:> ReqBody '[JSON] SendVenueRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendContact"
:> ReqBody '[JSON] SendContactRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "sendChatAction"
:> ReqBody '[JSON] SendChatActionRequest
:> Post '[JSON] ChatActionResponse
:<|> TelegramToken :> "getUpdates"
:> QueryParam "offset" Int
:> QueryParam "limit" Int
:> QueryParam "timeout" Int
:> Get '[JSON] UpdatesResponse
:<|> TelegramToken :> "getFile"
:> QueryParam "file_id" Text
:> Get '[JSON] FileResponse
:<|> TelegramToken :> "getUserProfilePhotos"
:> QueryParam "user_id" Int
:> QueryParam "offset" Int
:> QueryParam "limit" Int
:> Get '[JSON] UserProfilePhotosResponse
:<|> TelegramToken :> "setWebhook"
:> QueryParam "url" Text
:> Get '[JSON] SetWebhookResponse
:<|> TelegramToken :> "answerInlineQuery"
:> ReqBody '[JSON] AnswerInlineQueryRequest
:> Post '[JSON] InlineQueryResponse
:<|> TelegramToken :> "answerCallbackQuery"
:> ReqBody '[JSON] AnswerCallbackQueryRequest
:> Post '[JSON] CallbackQueryResponse
:<|> 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
:<|> TelegramToken :> "editMessageText"
:> ReqBody '[JSON] EditMessageTextRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "editMessageCaption"
:> ReqBody '[JSON] EditMessageCaptionRequest
:> Post '[JSON] MessageResponse
:<|> TelegramToken :> "editMessageReplyMarkup"
:> ReqBody '[JSON] EditMessageReplyMarkupRequest
:> Post '[JSON] MessageResponse
api :: Proxy TelegramBotAPI
api = Proxy
getMe_ :: Token -> Manager -> BaseUrl -> ExceptT ServantError IO GetMeResponse
sendMessage_ :: Token -> SendMessageRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
forwardMessage_ :: Token -> ForwardMessageRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
uploadPhoto_ :: Token -> SendPhotoRequest FileUpload -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendPhoto_ :: Token -> SendPhotoRequest Text -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
uploadAudio_ :: Token -> SendAudioRequest FileUpload -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendAudio_ :: Token -> SendAudioRequest Text -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
uploadDocument_ :: Token -> SendDocumentRequest FileUpload -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendDocument_ :: Token -> SendDocumentRequest Text -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
uploadSticker_ :: Token -> SendStickerRequest FileUpload -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendSticker_ :: Token -> SendStickerRequest Text -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
uploadVideo_ :: Token -> SendVideoRequest FileUpload -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendVideo_ :: Token -> SendVideoRequest Text -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
uploadVoice_ :: Token -> SendVoiceRequest FileUpload -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendVoice_ :: Token -> SendVoiceRequest Text -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendLocation_ :: Token -> SendLocationRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendVenue_ :: Token -> SendVenueRequest-> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendContact_ :: Token -> SendContactRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
sendChatAction_ :: Token -> SendChatActionRequest -> Manager -> BaseUrl -> ExceptT ServantError IO ChatActionResponse
getUpdates_ :: Token -> Maybe Int -> Maybe Int -> Maybe Int -> Manager -> BaseUrl -> ExceptT ServantError IO UpdatesResponse
getFile_ :: Token -> Maybe Text -> Manager -> BaseUrl -> ExceptT ServantError IO FileResponse
getUserProfilePhotos_ :: Token -> Maybe Int -> Maybe Int -> Maybe Int -> Manager -> BaseUrl -> ExceptT ServantError IO UserProfilePhotosResponse
setWebhook_ :: Token -> Maybe Text -> Manager -> BaseUrl -> ExceptT ServantError IO SetWebhookResponse
answerInlineQuery_ :: Token -> AnswerInlineQueryRequest -> Manager -> BaseUrl -> ExceptT ServantError IO InlineQueryResponse
answerCallbackQuery_ :: Token -> AnswerCallbackQueryRequest -> Manager -> BaseUrl -> ExceptT ServantError IO CallbackQueryResponse
kickChatMember_ :: Token -> Maybe Text -> Maybe Int -> Manager -> BaseUrl -> ExceptT ServantError IO KickChatMemberResponse
leaveChat_ :: Token -> Maybe Text -> Manager -> BaseUrl -> ExceptT ServantError IO LeaveChatResponse
unbanChatMember_ :: Token -> Maybe Text -> Maybe Int -> Manager -> BaseUrl -> ExceptT ServantError IO UnbanChatMemberResponse
getChat_ :: Token -> Maybe Text -> Manager -> BaseUrl -> ExceptT ServantError IO GetChatResponse
getChatAdministrators_ :: Token -> Maybe Text -> Manager -> BaseUrl -> ExceptT ServantError IO GetChatAdministratorsResponse
getChatMembersCount_ :: Token -> Maybe Text -> Manager -> BaseUrl -> ExceptT ServantError IO GetChatMembersCountResponse
getChatMember_ :: Token -> Maybe Text -> Maybe Int -> Manager -> BaseUrl -> ExceptT ServantError IO GetChatMemberResponse
editMessageText_ :: Token -> EditMessageTextRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
editMessageCaption_ :: Token -> EditMessageCaptionRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
editMessageReplyMarkup_ :: Token -> EditMessageReplyMarkupRequest -> Manager -> BaseUrl -> ExceptT ServantError IO MessageResponse
getMe_
:<|> sendMessage_
:<|> forwardMessage_
:<|> uploadPhoto_
:<|> sendPhoto_
:<|> uploadAudio_
:<|> sendAudio_
:<|> uploadDocument_
:<|> sendDocument_
:<|> uploadSticker_
:<|> sendSticker_
:<|> uploadVideo_
:<|> sendVideo_
:<|> uploadVoice_
:<|> sendVoice_
:<|> sendLocation_
:<|> sendVenue_
:<|> sendContact_
:<|> sendChatAction_
:<|> getUpdates_
:<|> getFile_
:<|> getUserProfilePhotos_
:<|> setWebhook_
:<|> answerInlineQuery_
:<|> answerCallbackQuery_
:<|> kickChatMember_
:<|> leaveChat_
:<|> unbanChatMember_
:<|> getChat_
:<|> getChatAdministrators_
:<|> getChatMembersCount_
:<|> getChatMember_
:<|> editMessageText_
:<|> editMessageCaption_
:<|> editMessageReplyMarkup_ =
client api
getMe :: Token -> Manager -> IO (Either ServantError GetMeResponse)
getMe token manager = runExceptT $ getMe_ token manager telegramBaseUrl
sendMessage :: Token -> SendMessageRequest -> Manager -> IO (Either ServantError MessageResponse)
sendMessage = run telegramBaseUrl sendMessage_
forwardMessage :: Token -> ForwardMessageRequest -> Manager -> IO (Either ServantError MessageResponse)
forwardMessage = run telegramBaseUrl forwardMessage_
uploadPhoto :: Token -> SendPhotoRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
uploadPhoto = run telegramBaseUrl uploadPhoto_
sendPhoto :: Token -> SendPhotoRequest Text -> Manager -> IO (Either ServantError MessageResponse)
sendPhoto = run telegramBaseUrl sendPhoto_
uploadAudio :: Token -> SendAudioRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
uploadAudio = run telegramBaseUrl uploadAudio_
sendAudio :: Token -> SendAudioRequest Text -> Manager -> IO (Either ServantError MessageResponse)
sendAudio = run telegramBaseUrl sendAudio_
uploadDocument :: Token -> SendDocumentRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
uploadDocument = run telegramBaseUrl uploadDocument_
sendDocument :: Token -> SendDocumentRequest Text -> Manager -> IO (Either ServantError MessageResponse)
sendDocument = run telegramBaseUrl sendDocument_
uploadSticker :: Token -> SendStickerRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
uploadSticker = run telegramBaseUrl uploadSticker_
sendSticker :: Token -> SendStickerRequest Text -> Manager -> IO (Either ServantError MessageResponse)
sendSticker = run telegramBaseUrl sendSticker_
uploadVideo :: Token -> SendVideoRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
uploadVideo = run telegramBaseUrl uploadVideo_
sendVideo :: Token -> SendVideoRequest Text -> Manager -> IO (Either ServantError MessageResponse)
sendVideo = run telegramBaseUrl sendVideo_
uploadVoice :: Token -> SendVoiceRequest FileUpload -> Manager -> IO (Either ServantError MessageResponse)
uploadVoice = run telegramBaseUrl uploadVoice_
sendVoice :: Token -> SendVoiceRequest Text -> Manager -> IO (Either ServantError MessageResponse)
sendVoice = run telegramBaseUrl sendVoice_
sendLocation :: Token -> SendLocationRequest -> Manager -> IO (Either ServantError MessageResponse)
sendLocation = run telegramBaseUrl sendLocation_
sendVenue :: Token -> SendVenueRequest -> Manager -> IO (Either ServantError MessageResponse)
sendVenue = run telegramBaseUrl sendVenue_
sendContact :: Token -> SendContactRequest -> Manager -> IO (Either ServantError MessageResponse)
sendContact = run telegramBaseUrl sendContact_
sendChatAction :: Token -> SendChatActionRequest -> Manager -> IO (Either ServantError ChatActionResponse)
sendChatAction = run telegramBaseUrl sendChatAction_
getUpdates :: Token -> Maybe Int -> Maybe Int -> Maybe Int -> Manager -> IO (Either ServantError UpdatesResponse)
getUpdates token offset limit timeout manager = runExceptT $ getUpdates_ token offset limit timeout manager telegramBaseUrl
getFile :: Token -> Text -> Manager -> IO (Either ServantError FileResponse)
getFile token file_id manager = runExceptT $ getFile_ token (Just file_id) manager telegramBaseUrl
getUserProfilePhotos :: Token -> Int -> Maybe Int -> Maybe Int -> Manager -> IO (Either ServantError UserProfilePhotosResponse)
getUserProfilePhotos token user_id offset limit manager = runExceptT $ getUserProfilePhotos_ token (Just user_id) offset limit manager telegramBaseUrl
setWebhook :: Token
-> Maybe Text
-> Manager
-> IO (Either ServantError SetWebhookResponse)
setWebhook token url manager = runExceptT $ setWebhook_ token url manager telegramBaseUrl
answerInlineQuery :: Token -> AnswerInlineQueryRequest -> Manager -> IO (Either ServantError InlineQueryResponse)
answerInlineQuery = run telegramBaseUrl answerInlineQuery_
answerCallbackQuery :: Token -> AnswerCallbackQueryRequest -> Manager -> IO (Either ServantError CallbackQueryResponse)
answerCallbackQuery = run telegramBaseUrl answerCallbackQuery_
kickChatMember :: Token -> Text -> Int -> Manager -> IO (Either ServantError KickChatMemberResponse)
kickChatMember token chat_id user_id manager = runExceptT $ kickChatMember_ token (Just chat_id) (Just user_id) manager telegramBaseUrl
leaveChat :: Token -> Text -> Manager -> IO (Either ServantError LeaveChatResponse)
leaveChat token chat_id manager = runExceptT $ leaveChat_ token (Just chat_id) manager telegramBaseUrl
unbanChatMember :: Token -> Text -> Int -> Manager -> IO (Either ServantError UnbanChatMemberResponse)
unbanChatMember token chat_id user_id manager = runExceptT $ unbanChatMember_ token (Just chat_id) (Just user_id) manager telegramBaseUrl
getChat :: Token -> Text -> Manager -> IO (Either ServantError GetChatResponse)
getChat token chat_id manager = runExceptT $ getChat_ token (Just chat_id) manager telegramBaseUrl
getChatAdministrators :: Token -> Text -> Manager -> IO (Either ServantError GetChatAdministratorsResponse)
getChatAdministrators token chat_id manager = runExceptT $ getChatAdministrators_ token (Just chat_id) manager telegramBaseUrl
getChatMembersCount :: Token -> Text -> Manager -> IO (Either ServantError GetChatMembersCountResponse)
getChatMembersCount token chat_id manager = runExceptT $ getChatMembersCount_ token (Just chat_id) manager telegramBaseUrl
getChatMember :: Token -> Text -> Int -> Manager -> IO (Either ServantError GetChatMemberResponse)
getChatMember token chat_id user_id manager = runExceptT $ getChatMember_ token (Just chat_id) (Just user_id) manager telegramBaseUrl
editMessageText :: Token -> EditMessageTextRequest -> Manager -> IO (Either ServantError MessageResponse)
editMessageText = run telegramBaseUrl editMessageText_
editMessageCaption :: Token -> EditMessageCaptionRequest -> Manager -> IO (Either ServantError MessageResponse)
editMessageCaption = run telegramBaseUrl editMessageCaption_
editMessageReplyMarkup :: Token -> EditMessageReplyMarkupRequest -> Manager -> IO (Either ServantError MessageResponse)
editMessageReplyMarkup = run telegramBaseUrl editMessageReplyMarkup_
run :: BaseUrl -> (Token -> a -> Manager -> BaseUrl -> ExceptT ServantError IO b) -> Token -> a -> Manager -> IO (Either ServantError b)
run b e t r m = runExceptT $ e t r m b