module TD.Query.ForwardMessages
  (ForwardMessages(..)
  , defaultForwardMessages
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.MessageSendOptions as MessageSendOptions

-- | Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message. Returns 'TD.Data.Messages.Messages'
data ForwardMessages
  = ForwardMessages
    { ForwardMessages -> Maybe Int
chat_id           :: Maybe Int                                   -- ^ Identifier of the chat to which to forward messages
    , ForwardMessages -> Maybe Int
message_thread_id :: Maybe Int                                   -- ^ If not 0, the message thread identifier in which the message will be sent; for forum threads only
    , ForwardMessages -> Maybe Int
from_chat_id      :: Maybe Int                                   -- ^ Identifier of the chat from which to forward messages
    , ForwardMessages -> Maybe [Int]
message_ids       :: Maybe [Int]                                 -- ^ Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order. At most 100 messages can be forwarded simultaneously. A message can be forwarded only if messageProperties.can_be_forwarded
    , ForwardMessages -> Maybe MessageSendOptions
options           :: Maybe MessageSendOptions.MessageSendOptions -- ^ Options to be used to send the messages; pass null to use default options
    , ForwardMessages -> Maybe Bool
send_copy         :: Maybe Bool                                  -- ^ Pass true to copy content of the messages without reference to the original sender. Always true if the messages are forwarded to a secret chat or are local. Use messageProperties.can_be_saved and messageProperties.can_be_copied_to_secret_chat to check whether the message is suitable
    , ForwardMessages -> Maybe Bool
remove_caption    :: Maybe Bool                                  -- ^ Pass true to remove media captions of message copies. Ignored if send_copy is false
    }
  deriving (ForwardMessages -> ForwardMessages -> Bool
(ForwardMessages -> ForwardMessages -> Bool)
-> (ForwardMessages -> ForwardMessages -> Bool)
-> Eq ForwardMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ForwardMessages -> ForwardMessages -> Bool
== :: ForwardMessages -> ForwardMessages -> Bool
$c/= :: ForwardMessages -> ForwardMessages -> Bool
/= :: ForwardMessages -> ForwardMessages -> Bool
Eq, Int -> ForwardMessages -> ShowS
[ForwardMessages] -> ShowS
ForwardMessages -> String
(Int -> ForwardMessages -> ShowS)
-> (ForwardMessages -> String)
-> ([ForwardMessages] -> ShowS)
-> Show ForwardMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ForwardMessages -> ShowS
showsPrec :: Int -> ForwardMessages -> ShowS
$cshow :: ForwardMessages -> String
show :: ForwardMessages -> String
$cshowList :: [ForwardMessages] -> ShowS
showList :: [ForwardMessages] -> ShowS
Show)

instance I.ShortShow ForwardMessages where
  shortShow :: ForwardMessages -> String
shortShow
    ForwardMessages
      { chat_id :: ForwardMessages -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: ForwardMessages -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      , from_chat_id :: ForwardMessages -> Maybe Int
from_chat_id      = Maybe Int
from_chat_id_
      , message_ids :: ForwardMessages -> Maybe [Int]
message_ids       = Maybe [Int]
message_ids_
      , options :: ForwardMessages -> Maybe MessageSendOptions
options           = Maybe MessageSendOptions
options_
      , send_copy :: ForwardMessages -> Maybe Bool
send_copy         = Maybe Bool
send_copy_
      , remove_caption :: ForwardMessages -> Maybe Bool
remove_caption    = Maybe Bool
remove_caption_
      }
        = String
"ForwardMessages"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"message_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
          , String
"from_chat_id"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
from_chat_id_
          , String
"message_ids"       String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
message_ids_
          , String
"options"           String -> Maybe MessageSendOptions -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSendOptions
options_
          , String
"send_copy"         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
send_copy_
          , String
"remove_caption"    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
remove_caption_
          ]

instance AT.ToJSON ForwardMessages where
  toJSON :: ForwardMessages -> Value
toJSON
    ForwardMessages
      { chat_id :: ForwardMessages -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: ForwardMessages -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      , from_chat_id :: ForwardMessages -> Maybe Int
from_chat_id      = Maybe Int
from_chat_id_
      , message_ids :: ForwardMessages -> Maybe [Int]
message_ids       = Maybe [Int]
message_ids_
      , options :: ForwardMessages -> Maybe MessageSendOptions
options           = Maybe MessageSendOptions
options_
      , send_copy :: ForwardMessages -> Maybe Bool
send_copy         = Maybe Bool
send_copy_
      , remove_caption :: ForwardMessages -> Maybe Bool
remove_caption    = Maybe Bool
remove_caption_
      }
        = [Pair] -> Value
A.object
          [ Key
"@type"             Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"forwardMessages"
          , Key
"chat_id"           Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
chat_id_
          , Key
"message_thread_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
message_thread_id_
          , Key
"from_chat_id"      Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
from_chat_id_
          , Key
"message_ids"       Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
message_ids_
          , Key
"options"           Key -> Maybe MessageSendOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSendOptions
options_
          , Key
"send_copy"         Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
send_copy_
          , Key
"remove_caption"    Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
remove_caption_
          ]

defaultForwardMessages :: ForwardMessages
defaultForwardMessages :: ForwardMessages
defaultForwardMessages =
  ForwardMessages
    { chat_id :: Maybe Int
chat_id           = Maybe Int
forall a. Maybe a
Nothing
    , message_thread_id :: Maybe Int
message_thread_id = Maybe Int
forall a. Maybe a
Nothing
    , from_chat_id :: Maybe Int
from_chat_id      = Maybe Int
forall a. Maybe a
Nothing
    , message_ids :: Maybe [Int]
message_ids       = Maybe [Int]
forall a. Maybe a
Nothing
    , options :: Maybe MessageSendOptions
options           = Maybe MessageSendOptions
forall a. Maybe a
Nothing
    , send_copy :: Maybe Bool
send_copy         = Maybe Bool
forall a. Maybe a
Nothing
    , remove_caption :: Maybe Bool
remove_caption    = Maybe Bool
forall a. Maybe a
Nothing
    }