module TD.Query.GetMessages
  (GetMessages(..)
  , defaultGetMessages
  ) where

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

-- | Returns information about messages. If a message is not found, returns null on the corresponding position of the result. Returns 'TD.Data.Messages.Messages'
data GetMessages
  = GetMessages
    { GetMessages -> Maybe Int
chat_id     :: Maybe Int   -- ^ Identifier of the chat the messages belong to
    , GetMessages -> Maybe [Int]
message_ids :: Maybe [Int] -- ^ Identifiers of the messages to get
    }
  deriving (GetMessages -> GetMessages -> Bool
(GetMessages -> GetMessages -> Bool)
-> (GetMessages -> GetMessages -> Bool) -> Eq GetMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetMessages -> GetMessages -> Bool
== :: GetMessages -> GetMessages -> Bool
$c/= :: GetMessages -> GetMessages -> Bool
/= :: GetMessages -> GetMessages -> Bool
Eq, Int -> GetMessages -> ShowS
[GetMessages] -> ShowS
GetMessages -> String
(Int -> GetMessages -> ShowS)
-> (GetMessages -> String)
-> ([GetMessages] -> ShowS)
-> Show GetMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetMessages -> ShowS
showsPrec :: Int -> GetMessages -> ShowS
$cshow :: GetMessages -> String
show :: GetMessages -> String
$cshowList :: [GetMessages] -> ShowS
showList :: [GetMessages] -> ShowS
Show)

instance I.ShortShow GetMessages where
  shortShow :: GetMessages -> String
shortShow
    GetMessages
      { chat_id :: GetMessages -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , message_ids :: GetMessages -> Maybe [Int]
message_ids = Maybe [Int]
message_ids_
      }
        = String
"GetMessages"
          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_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
message_ids_
          ]

instance AT.ToJSON GetMessages where
  toJSON :: GetMessages -> Value
toJSON
    GetMessages
      { chat_id :: GetMessages -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , message_ids :: GetMessages -> Maybe [Int]
message_ids = Maybe [Int]
message_ids_
      }
        = [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
"getMessages"
          , 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_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_
          ]

defaultGetMessages :: GetMessages
defaultGetMessages :: GetMessages
defaultGetMessages =
  GetMessages
    { chat_id :: Maybe Int
chat_id     = Maybe Int
forall a. Maybe a
Nothing
    , message_ids :: Maybe [Int]
message_ids = Maybe [Int]
forall a. Maybe a
Nothing
    }