module TD.Query.OpenSponsoredChat
  (OpenSponsoredChat(..)
  ) where

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

-- | Informs TDLib that the user opened a sponsored chat. Returns 'TD.Data.Ok.Ok'
data OpenSponsoredChat
  = OpenSponsoredChat
    {  :: Maybe Int -- ^ Unique identifier of the sponsored chat
    }
  deriving (OpenSponsoredChat -> OpenSponsoredChat -> Bool
(OpenSponsoredChat -> OpenSponsoredChat -> Bool)
-> (OpenSponsoredChat -> OpenSponsoredChat -> Bool)
-> Eq OpenSponsoredChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OpenSponsoredChat -> OpenSponsoredChat -> Bool
== :: OpenSponsoredChat -> OpenSponsoredChat -> Bool
$c/= :: OpenSponsoredChat -> OpenSponsoredChat -> Bool
/= :: OpenSponsoredChat -> OpenSponsoredChat -> Bool
Eq, Int -> OpenSponsoredChat -> ShowS
[OpenSponsoredChat] -> ShowS
OpenSponsoredChat -> String
(Int -> OpenSponsoredChat -> ShowS)
-> (OpenSponsoredChat -> String)
-> ([OpenSponsoredChat] -> ShowS)
-> Show OpenSponsoredChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OpenSponsoredChat -> ShowS
showsPrec :: Int -> OpenSponsoredChat -> ShowS
$cshow :: OpenSponsoredChat -> String
show :: OpenSponsoredChat -> String
$cshowList :: [OpenSponsoredChat] -> ShowS
showList :: [OpenSponsoredChat] -> ShowS
Show)

instance I.ShortShow OpenSponsoredChat where
  shortShow :: OpenSponsoredChat -> String
shortShow
    OpenSponsoredChat
      { sponsored_chat_unique_id :: OpenSponsoredChat -> Maybe Int
sponsored_chat_unique_id = Maybe Int
sponsored_chat_unique_id_
      }
        = String
"OpenSponsoredChat"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"sponsored_chat_unique_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
sponsored_chat_unique_id_
          ]

instance AT.ToJSON OpenSponsoredChat where
  toJSON :: OpenSponsoredChat -> Value
toJSON
    OpenSponsoredChat
      { sponsored_chat_unique_id :: OpenSponsoredChat -> Maybe Int
sponsored_chat_unique_id = Maybe Int
sponsored_chat_unique_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
"openSponsoredChat"
          , Key
"sponsored_chat_unique_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
sponsored_chat_unique_id_
          ]