{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TemplateHaskell #-}
module Telegram.Bot.API.UpdatingMessages where
import Data.Aeson
import Data.Proxy
import Data.Text (Text)
import GHC.Generics (Generic)
import Servant.API
import Servant.Client (ClientM, client)
import Telegram.Bot.API.Internal.Utils (deriveJSON', gtoJSON)
import Telegram.Bot.API.MakingRequests
import Telegram.Bot.API.Methods
import Telegram.Bot.API.Types
data EditMessageResponse
= EditedInlineMessage Bool
| EditedMessage Message
deriving (Int -> EditMessageResponse -> ShowS
[EditMessageResponse] -> ShowS
EditMessageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EditMessageResponse] -> ShowS
$cshowList :: [EditMessageResponse] -> ShowS
show :: EditMessageResponse -> String
$cshow :: EditMessageResponse -> String
showsPrec :: Int -> EditMessageResponse -> ShowS
$cshowsPrec :: Int -> EditMessageResponse -> ShowS
Show, forall x. Rep EditMessageResponse x -> EditMessageResponse
forall x. EditMessageResponse -> Rep EditMessageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EditMessageResponse x -> EditMessageResponse
$cfrom :: forall x. EditMessageResponse -> Rep EditMessageResponse x
Generic)
instance FromJSON EditMessageResponse where
parseJSON :: Value -> Parser EditMessageResponse
parseJSON (Data.Aeson.Bool Bool
b) = forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool -> EditMessageResponse
EditedInlineMessage Bool
b)
parseJSON o :: Value
o@(Data.Aeson.Object Object
_) = Message -> EditMessageResponse
EditedMessage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Value -> Parser a
parseJSON Value
o
parseJSON Value
_ = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Unable to parse EditMessageResponse: expected either a Bool or a Message"
data EditMessageTextRequest = EditMessageTextRequest
{ EditMessageTextRequest -> Maybe SomeChatId
editMessageTextChatId :: Maybe SomeChatId
, EditMessageTextRequest -> Maybe MessageId
editMessageTextMessageId :: Maybe MessageId
, EditMessageTextRequest -> Maybe MessageId
editMessageTextInlineMessageId :: Maybe MessageId
, EditMessageTextRequest -> Text
editMessageTextText :: Text
, EditMessageTextRequest -> Maybe ParseMode
editMessageTextParseMode :: Maybe ParseMode
, EditMessageTextRequest -> Maybe [MessageEntity]
editMessageEntities :: Maybe [MessageEntity]
, EditMessageTextRequest -> Maybe Bool
editMessageTextDisableWebPagePreview :: Maybe Bool
, EditMessageTextRequest -> Maybe SomeReplyMarkup
editMessageTextReplyMarkup :: Maybe SomeReplyMarkup
} deriving (forall x. Rep EditMessageTextRequest x -> EditMessageTextRequest
forall x. EditMessageTextRequest -> Rep EditMessageTextRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EditMessageTextRequest x -> EditMessageTextRequest
$cfrom :: forall x. EditMessageTextRequest -> Rep EditMessageTextRequest x
Generic)
data EditMessageCaptionRequest = EditMessageCaptionRequest
{ EditMessageCaptionRequest -> Maybe SomeChatId
editMessageCaptionChatId :: Maybe SomeChatId
, EditMessageCaptionRequest -> Maybe MessageId
editMessageCaptionMessageId :: Maybe MessageId
, EditMessageCaptionRequest -> Maybe MessageId
editMessageCaptionInlineMessageId :: Maybe MessageId
, EditMessageCaptionRequest -> Maybe Text
editMessageCaptionCaption :: Maybe Text
, EditMessageCaptionRequest -> Maybe ParseMode
editMessageCaptionParseMode :: Maybe ParseMode
, EditMessageCaptionRequest -> Maybe [MessageEntity]
editMessageCaptionCaptionEntities :: Maybe [MessageEntity]
, EditMessageCaptionRequest -> Maybe SomeReplyMarkup
editMessageCaptionReplyMarkup :: Maybe SomeReplyMarkup
} deriving (forall x.
Rep EditMessageCaptionRequest x -> EditMessageCaptionRequest
forall x.
EditMessageCaptionRequest -> Rep EditMessageCaptionRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EditMessageCaptionRequest x -> EditMessageCaptionRequest
$cfrom :: forall x.
EditMessageCaptionRequest -> Rep EditMessageCaptionRequest x
Generic)
data EditMessageMediaRequest = EditMessageMediaRequest
{ EditMessageMediaRequest -> Maybe SomeChatId
editMessageMediaChatId :: Maybe SomeChatId
, EditMessageMediaRequest -> Maybe MessageId
editMessageMediaMessageId :: Maybe MessageId
, EditMessageMediaRequest -> Maybe MessageId
editMessageMediaInlineMessageId :: Maybe MessageId
, EditMessageMediaRequest -> InputMedia
editMessageMediaMedia :: InputMedia
, EditMessageMediaRequest -> Maybe SomeReplyMarkup
editMessageMediaReplyMarkup :: Maybe SomeReplyMarkup
} deriving (forall x. Rep EditMessageMediaRequest x -> EditMessageMediaRequest
forall x. EditMessageMediaRequest -> Rep EditMessageMediaRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EditMessageMediaRequest x -> EditMessageMediaRequest
$cfrom :: forall x. EditMessageMediaRequest -> Rep EditMessageMediaRequest x
Generic)
instance ToJSON EditMessageMediaRequest where toJSON :: EditMessageMediaRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
data EditMessageReplyMarkupRequest = EditMessageReplyMarkupRequest
{ EditMessageReplyMarkupRequest -> Maybe SomeChatId
editMessageReplyMarkupChatId :: Maybe SomeChatId
, EditMessageReplyMarkupRequest -> Maybe MessageId
editMessageReplyMarkupMessageId :: Maybe MessageId
, EditMessageReplyMarkupRequest -> Maybe MessageId
editMessageReplyMarkupInlineMessageId :: Maybe MessageId
, EditMessageReplyMarkupRequest -> Maybe SomeReplyMarkup
editMessageReplyMarkupReplyMarkup :: Maybe SomeReplyMarkup
} deriving (forall x.
Rep EditMessageReplyMarkupRequest x
-> EditMessageReplyMarkupRequest
forall x.
EditMessageReplyMarkupRequest
-> Rep EditMessageReplyMarkupRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EditMessageReplyMarkupRequest x
-> EditMessageReplyMarkupRequest
$cfrom :: forall x.
EditMessageReplyMarkupRequest
-> Rep EditMessageReplyMarkupRequest x
Generic)
data StopPollRequest = StopPollRequest
{ StopPollRequest -> SomeChatId
stopPollChatId :: SomeChatId
, StopPollRequest -> MessageId
stopPollMessageId :: MessageId
, StopPollRequest -> Maybe SomeReplyMarkup
stopPollReplyMarkup :: Maybe SomeReplyMarkup
} deriving (forall x. Rep StopPollRequest x -> StopPollRequest
forall x. StopPollRequest -> Rep StopPollRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopPollRequest x -> StopPollRequest
$cfrom :: forall x. StopPollRequest -> Rep StopPollRequest x
Generic)
foldMap deriveJSON'
[ ''EditMessageTextRequest
, ''EditMessageCaptionRequest
, ''EditMessageReplyMarkupRequest
, ''StopPollRequest
]
type EditMessageText
= "editMessageText"
:> ReqBody '[JSON] EditMessageTextRequest
:> Post '[JSON] (Response EditMessageResponse)
editMessageText :: EditMessageTextRequest -> ClientM (Response EditMessageResponse)
editMessageText :: EditMessageTextRequest -> ClientM (Response EditMessageResponse)
editMessageText = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @EditMessageText)
type EditMessageCaption = "editMessageCaption"
:> ReqBody '[JSON] EditMessageCaptionRequest
:> Post '[JSON] (Response EditMessageResponse)
editMessageCaption :: EditMessageCaptionRequest -> ClientM (Response EditMessageResponse)
editMessageCaption :: EditMessageCaptionRequest -> ClientM (Response EditMessageResponse)
editMessageCaption = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @EditMessageCaption)
type EditMessageMedia = "editMessageMedia"
:> ReqBody '[JSON] EditMessageMediaRequest
:> Post '[JSON] (Response EditMessageResponse)
editMessageMedia :: EditMessageMediaRequest -> ClientM (Response EditMessageResponse)
editMessageMedia :: EditMessageMediaRequest -> ClientM (Response EditMessageResponse)
editMessageMedia = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @EditMessageMedia)
type EditMessageReplyMarkup = "editMessageReplyMarkup"
:> ReqBody '[JSON] EditMessageReplyMarkupRequest
:> Post '[JSON] (Response EditMessageResponse)
editMessageReplyMarkup :: EditMessageReplyMarkupRequest -> ClientM (Response EditMessageResponse)
editMessageReplyMarkup :: EditMessageReplyMarkupRequest
-> ClientM (Response EditMessageResponse)
editMessageReplyMarkup = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @EditMessageReplyMarkup)
type StopPoll = "stopPoll"
:> ReqBody '[JSON] StopPollRequest
:> Post '[JSON] (Response Poll)
stopPoll :: StopPollRequest -> ClientM (Response Poll)
stopPoll :: StopPollRequest -> ClientM (Response Poll)
stopPoll = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @StopPoll)