module TD.Query.GetChatSponsoredMessages
  (GetChatSponsoredMessages(..)
  ) where

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

-- | Returns sponsored messages to be shown in a chat; for channel chats only. Returns 'TD.Data.SponsoredMessages.SponsoredMessages'
data GetChatSponsoredMessages
  = GetChatSponsoredMessages
    { GetChatSponsoredMessages -> Maybe Int
chat_id :: Maybe Int -- ^ Identifier of the chat
    }
  deriving (GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool
(GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool)
-> (GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool)
-> Eq GetChatSponsoredMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool
== :: GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool
$c/= :: GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool
/= :: GetChatSponsoredMessages -> GetChatSponsoredMessages -> Bool
Eq, Int -> GetChatSponsoredMessages -> ShowS
[GetChatSponsoredMessages] -> ShowS
GetChatSponsoredMessages -> String
(Int -> GetChatSponsoredMessages -> ShowS)
-> (GetChatSponsoredMessages -> String)
-> ([GetChatSponsoredMessages] -> ShowS)
-> Show GetChatSponsoredMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatSponsoredMessages -> ShowS
showsPrec :: Int -> GetChatSponsoredMessages -> ShowS
$cshow :: GetChatSponsoredMessages -> String
show :: GetChatSponsoredMessages -> String
$cshowList :: [GetChatSponsoredMessages] -> ShowS
showList :: [GetChatSponsoredMessages] -> ShowS
Show)

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