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

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Proxy
import Data.Text
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
import Telegram.Bot.API.Types.ParseMode
import Telegram.Bot.API.Internal.TH

-- ** 'copyMessages'

type CopyMessages
  = "copyMessages"
  :> ReqBody '[JSON] CopyMessagesRequest
  :> Post '[JSON] (Response [CopyMessageId])

-- | Use this method to copy messages of any kind.
-- If some of the specified messages can't be found or copied, they are skipped.
-- Service messages, giveaway messages, giveaway winners messages,
-- and invoice messages can't be copied.
-- A quiz poll can be copied only if the value of the field @correct_option_id@ is knownto the bot.
-- The method is analogous to the method 'forwardMessages',
-- but the copied messages don't have a link to the original message.
-- Album grouping is kept for copied messages.
-- On success, an array of 'CopyMessageId' of the sent messages is returned.
copyMessages :: CopyMessagesRequest ->  ClientM (Response [CopyMessageId])
copyMessages :: CopyMessagesRequest -> ClientM (Response [CopyMessageId])
copyMessages = Proxy CopyMessages -> Client ClientM CopyMessages
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @CopyMessages)

-- | Request parameters for 'copyMessages'.
data CopyMessagesRequest = CopyMessagesRequest
  { CopyMessagesRequest -> SomeChatId
copyMessagesChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername).
  , CopyMessagesRequest -> Maybe Message
copyMessagesMessageThreadId :: Maybe Message -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.
  , CopyMessagesRequest -> SomeChatId
copyMessagesFromChatId :: SomeChatId -- ^ Unique identifier for the chat where the original message was sent (or channel username in the format \@channelusername).
  , CopyMessagesRequest -> [MessageId]
copyMessagesMessageIds :: [MessageId] -- ^ Identifiers of 1-100 messages in the chat @from_chat_id@ to copy. The identifiers must be specified in a strictly increasing order.
  , CopyMessagesRequest -> Maybe Text
copyMessagesCaption :: Maybe Text -- ^ New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
  , CopyMessagesRequest -> Maybe ParseMode
copyMessagesParseMode :: 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.
  , CopyMessagesRequest -> Maybe [MessageEntity]
copyMessagesCaptionEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
  , CopyMessagesRequest -> Maybe Bool
copyMessagesDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound.
  , CopyMessagesRequest -> Maybe Bool
copyMessagesProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving
  , CopyMessagesRequest -> Maybe Bool
copyMessagesRemoveCaption :: Maybe Bool -- ^ Pass 'True' to copy the messages without their captions.
  }
  deriving (forall x. CopyMessagesRequest -> Rep CopyMessagesRequest x)
-> (forall x. Rep CopyMessagesRequest x -> CopyMessagesRequest)
-> Generic CopyMessagesRequest
forall x. Rep CopyMessagesRequest x -> CopyMessagesRequest
forall x. CopyMessagesRequest -> Rep CopyMessagesRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CopyMessagesRequest -> Rep CopyMessagesRequest x
from :: forall x. CopyMessagesRequest -> Rep CopyMessagesRequest x
$cto :: forall x. Rep CopyMessagesRequest x -> CopyMessagesRequest
to :: forall x. Rep CopyMessagesRequest x -> CopyMessagesRequest
Generic

instance ToJSON   CopyMessagesRequest where toJSON :: CopyMessagesRequest -> Value
toJSON = CopyMessagesRequest -> Value
forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON CopyMessagesRequest where parseJSON :: Value -> Parser CopyMessagesRequest
parseJSON = Value -> Parser CopyMessagesRequest
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON

makeDefault ''CopyMessagesRequest