{-# 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

-- ** 'editMessageText'

-- | Request parameters for 'editMessageText'.
data EditMessageTextRequest = EditMessageTextRequest
  { EditMessageTextRequest -> Maybe SomeChatId
editMessageTextChatId                :: Maybe SomeChatId -- ^ Required if 'editMessageTextInlineMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@).
  , EditMessageTextRequest -> Maybe MessageId
editMessageTextMessageId             :: Maybe MessageId -- ^ Required if 'editMessageTextInlineMessageId' is not specified. Identifier of the sent message.
  , EditMessageTextRequest -> Maybe MessageId
editMessageTextInlineMessageId       :: Maybe MessageId -- ^ Required if 'editMessageTextChatId' and 'editMessageTextMessageId' are not specified. Identifier of the sent message.
  , EditMessageTextRequest -> Text
editMessageTextText                  :: Text -- ^ Text of the message to be sent.
  , EditMessageTextRequest -> Maybe ParseMode
editMessageTextParseMode             :: Maybe ParseMode -- ^ Send 'MarkdownV2', 'HTML' or 'Markdown' (legacy), if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
  , EditMessageTextRequest -> Maybe [MessageEntity]
editMessageEntities                  :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in message text, which can be specified instead of /parse_mode/.
  , EditMessageTextRequest -> Maybe Bool
editMessageTextDisableWebPagePreview :: Maybe Bool -- ^ Disables link previews for links in this message.
  , EditMessageTextRequest -> Maybe SomeReplyMarkup
editMessageTextReplyMarkup           :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
} deriving ((forall x. EditMessageTextRequest -> Rep EditMessageTextRequest x)
-> (forall x.
    Rep EditMessageTextRequest x -> EditMessageTextRequest)
-> Generic EditMessageTextRequest
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)

-- | Request parameters for 'editMessageCaption'.
data EditMessageCaptionRequest = EditMessageCaptionRequest
  { EditMessageCaptionRequest -> Maybe SomeChatId
editMessageCaptionChatId           :: Maybe SomeChatId -- ^ Required if 'editMessageCaptionMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@).
  , EditMessageCaptionRequest -> Maybe MessageId
editMessageCaptionMessageId        :: Maybe MessageId -- ^ Required if 'editMessageCaptionInlineMessageId' is not specified. Identifier of the sent message.
  , EditMessageCaptionRequest -> Maybe MessageId
editMessageCaptionInlineMessageId  :: Maybe MessageId -- ^ Required if 'editMessageCaptionChatId' and 'editMessageCaptionMessageId' are not specified. Identifier of the sent message.
  , EditMessageCaptionRequest -> Maybe Text
editMessageCaptionCaption          :: Maybe Text -- ^ New caption of the message, 0-1024 characters after entities parsing
  , EditMessageCaptionRequest -> Maybe ParseMode
editMessageCaptionParseMode        :: Maybe ParseMode -- ^ Mode for parsing entities in the message caption. See formatting options for more details.
  , EditMessageCaptionRequest -> Maybe [MessageEntity]
editMessageCaptionCaptionEntities  :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
  , EditMessageCaptionRequest -> Maybe SomeReplyMarkup
editMessageCaptionReplyMarkup      :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
} deriving ((forall x.
 EditMessageCaptionRequest -> Rep EditMessageCaptionRequest x)
-> (forall x.
    Rep EditMessageCaptionRequest x -> EditMessageCaptionRequest)
-> Generic EditMessageCaptionRequest
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)

-- | Request parameters for 'editMessageMedia'.
data EditMessageMediaRequest = EditMessageMediaRequest
  { EditMessageMediaRequest -> Maybe SomeChatId
editMessageMediaChatId           :: Maybe SomeChatId -- ^ Required if 'editMessageMediaMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@).
  , EditMessageMediaRequest -> Maybe MessageId
editMessageMediaMessageId        :: Maybe MessageId -- ^ Required if 'editMessageMediaInlineMessageId' is not specified. Identifier of the sent message.
  , EditMessageMediaRequest -> Maybe MessageId
editMessageMediaInlineMessageId  :: Maybe MessageId -- ^ Required if 'editMessageMediaChatId' and 'editMessageMediaMessageId' are not specified. Identifier of the sent message.
  , EditMessageMediaRequest -> InputMedia
editMessageMediaMedia            :: InputMedia -- ^ A JSON-serialized object for a new media content of the message
  , EditMessageMediaRequest -> Maybe SomeReplyMarkup
editMessageMediaReplyMarkup      :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
} deriving ((forall x.
 EditMessageMediaRequest -> Rep EditMessageMediaRequest x)
-> (forall x.
    Rep EditMessageMediaRequest x -> EditMessageMediaRequest)
-> Generic EditMessageMediaRequest
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 = EditMessageMediaRequest -> Value
forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

-- | Request parameters for 'editMessageReplyMarkup'.
data EditMessageReplyMarkupRequest = EditMessageReplyMarkupRequest
  { EditMessageReplyMarkupRequest -> Maybe SomeChatId
editMessageReplyMarkupChatId           :: Maybe SomeChatId -- ^ Required if 'editMessageReplyMarkupMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@).
  , EditMessageReplyMarkupRequest -> Maybe MessageId
editMessageReplyMarkupMessageId        :: Maybe MessageId -- ^ Required if 'editMessageReplyMarkupInlineMessageId' is not specified. Identifier of the sent message.
  , EditMessageReplyMarkupRequest -> Maybe MessageId
editMessageReplyMarkupInlineMessageId  :: Maybe MessageId -- ^ Required if 'editMessageReplyMarkupChatId' and 'editMessageReplyMarkupMessageId' are not specified. Identifier of the sent message.
  , EditMessageReplyMarkupRequest -> Maybe SomeReplyMarkup
editMessageReplyMarkupReplyMarkup      :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
} deriving ((forall x.
 EditMessageReplyMarkupRequest
 -> Rep EditMessageReplyMarkupRequest x)
-> (forall x.
    Rep EditMessageReplyMarkupRequest x
    -> EditMessageReplyMarkupRequest)
-> Generic EditMessageReplyMarkupRequest
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)

-- | Request parameters for 'stopPoll'.
data StopPollRequest = StopPollRequest
  { StopPollRequest -> SomeChatId
stopPollChatId           :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername)
  , StopPollRequest -> MessageId
stopPollMessageId        :: MessageId -- ^ Identifier of the original message with the poll
  , StopPollRequest -> Maybe SomeReplyMarkup
stopPollReplyMarkup      :: Maybe SomeReplyMarkup -- ^ A JSON-serialized object for a new message inline keyboard.
  } deriving ((forall x. StopPollRequest -> Rep StopPollRequest x)
-> (forall x. Rep StopPollRequest x -> StopPollRequest)
-> Generic StopPollRequest
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 (Either Bool Message))

-- | Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited 'Message' is returned, otherwise 'True' is returned.
editMessageText :: EditMessageTextRequest -> ClientM (Response (Either Bool Message))
editMessageText :: EditMessageTextRequest -> ClientM (Response (Either Bool Message))
editMessageText = Proxy EditMessageText -> Client ClientM EditMessageText
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy EditMessageText
forall k (t :: k). Proxy t
Proxy @EditMessageText)

type EditMessageCaption  = "editMessageCaption"
  :> ReqBody '[JSON] EditMessageCaptionRequest
  :> Post '[JSON] (Response (Either Bool Message))

-- | Use this method to edit captions of messages.
--   On success, if the edited message is not an
--   inline message, the edited Message is returned,
--   otherwise True is returned.
editMessageCaption :: EditMessageCaptionRequest -> ClientM (Response (Either Bool Message))
editMessageCaption :: EditMessageCaptionRequest
-> ClientM (Response (Either Bool Message))
editMessageCaption = Proxy EditMessageCaption -> Client ClientM EditMessageCaption
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy EditMessageCaption
forall k (t :: k). Proxy t
Proxy @EditMessageCaption)

type EditMessageMedia  = "editMessageMedia"
  :> ReqBody '[JSON] EditMessageMediaRequest
  :> Post '[JSON] (Response (Either Bool Message))

-- | Use this method to edit animation, audio,
--   document, photo, or video messages. If a
--   message is part of a message album, then it
--   can be edited only to an audio for audio albums,
--   only to a document for document albums and to a
--   photo or a video otherwise. When an inline message
--   is edited, a new file can't be uploaded; use a
--   previously uploaded file via its file_id or specify a URL.
--   On success, if the edited message is not an inline
--   message, the edited Message is returned, otherwise True is returned.
editMessageMedia :: EditMessageMediaRequest -> ClientM (Response (Either Bool Message))
editMessageMedia :: EditMessageMediaRequest -> ClientM (Response (Either Bool Message))
editMessageMedia = Proxy EditMessageMedia -> Client ClientM EditMessageMedia
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy EditMessageMedia
forall k (t :: k). Proxy t
Proxy @EditMessageMedia)


type EditMessageReplyMarkup = "editMessageReplyMarkup"
  :> ReqBody '[JSON] EditMessageReplyMarkupRequest
  :> Post '[JSON] (Response (Either Bool Message))

-- | Use this method to edit only the reply markup of messages.
--   On success, if the edited message is not an inline message,
--   the edited Message is returned, otherwise True is returned.
editMessageReplyMarkup :: EditMessageReplyMarkupRequest -> ClientM (Response (Either Bool Message))
editMessageReplyMarkup :: EditMessageReplyMarkupRequest
-> ClientM (Response (Either Bool Message))
editMessageReplyMarkup = Proxy EditMessageReplyMarkup
-> Client ClientM EditMessageReplyMarkup
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy EditMessageReplyMarkup
forall k (t :: k). Proxy t
Proxy @EditMessageReplyMarkup)

type StopPoll = "stopPoll"
  :> ReqBody '[JSON] StopPollRequest
  :> Post '[JSON] (Response Poll)

-- | Use this method to stop a poll which was sent by the bot.
--   On success, the stopped Poll is returned.
stopPoll :: StopPollRequest -> ClientM (Response Poll)
stopPoll :: StopPollRequest -> ClientM (Response Poll)
stopPoll = Proxy StopPoll -> Client ClientM StopPoll
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy StopPoll
forall k (t :: k). Proxy t
Proxy @StopPoll)