module TD.Query.GetChatPinnedMessage
  (GetChatPinnedMessage(..)
  ) where

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

-- | Returns information about a newest pinned message in the chat. Returns a 404 error if the message doesn't exist. Returns 'TD.Data.Message.Message'
data GetChatPinnedMessage
  = GetChatPinnedMessage
    { GetChatPinnedMessage -> Maybe Int
chat_id :: Maybe Int -- ^ Identifier of the chat the message belongs to
    }
  deriving (GetChatPinnedMessage -> GetChatPinnedMessage -> Bool
(GetChatPinnedMessage -> GetChatPinnedMessage -> Bool)
-> (GetChatPinnedMessage -> GetChatPinnedMessage -> Bool)
-> Eq GetChatPinnedMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatPinnedMessage -> GetChatPinnedMessage -> Bool
== :: GetChatPinnedMessage -> GetChatPinnedMessage -> Bool
$c/= :: GetChatPinnedMessage -> GetChatPinnedMessage -> Bool
/= :: GetChatPinnedMessage -> GetChatPinnedMessage -> Bool
Eq, Int -> GetChatPinnedMessage -> ShowS
[GetChatPinnedMessage] -> ShowS
GetChatPinnedMessage -> String
(Int -> GetChatPinnedMessage -> ShowS)
-> (GetChatPinnedMessage -> String)
-> ([GetChatPinnedMessage] -> ShowS)
-> Show GetChatPinnedMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatPinnedMessage -> ShowS
showsPrec :: Int -> GetChatPinnedMessage -> ShowS
$cshow :: GetChatPinnedMessage -> String
show :: GetChatPinnedMessage -> String
$cshowList :: [GetChatPinnedMessage] -> ShowS
showList :: [GetChatPinnedMessage] -> ShowS
Show)

instance I.ShortShow GetChatPinnedMessage where
  shortShow :: GetChatPinnedMessage -> String
shortShow
    GetChatPinnedMessage
      { chat_id :: GetChatPinnedMessage -> Maybe Int
chat_id = Maybe Int
chat_id_
      }
        = String
"GetChatPinnedMessage"
          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_
          ]

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