module TD.Query.GetTonConnectSessionNextEventId
  (GetTonConnectSessionNextEventId(..)
  ) where

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

-- | Returns the next event identifier for the given TON Connect session. Returns 'TD.Data.TonConnectSessionEventId.TonConnectSessionEventId'
data GetTonConnectSessionNextEventId
  = GetTonConnectSessionNextEventId
    { GetTonConnectSessionNextEventId -> Maybe Int
session_id :: Maybe Int -- ^ Unique identifier of the TON Connect session
    }
  deriving (GetTonConnectSessionNextEventId
-> GetTonConnectSessionNextEventId -> Bool
(GetTonConnectSessionNextEventId
 -> GetTonConnectSessionNextEventId -> Bool)
-> (GetTonConnectSessionNextEventId
    -> GetTonConnectSessionNextEventId -> Bool)
-> Eq GetTonConnectSessionNextEventId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTonConnectSessionNextEventId
-> GetTonConnectSessionNextEventId -> Bool
== :: GetTonConnectSessionNextEventId
-> GetTonConnectSessionNextEventId -> Bool
$c/= :: GetTonConnectSessionNextEventId
-> GetTonConnectSessionNextEventId -> Bool
/= :: GetTonConnectSessionNextEventId
-> GetTonConnectSessionNextEventId -> Bool
Eq, Int -> GetTonConnectSessionNextEventId -> ShowS
[GetTonConnectSessionNextEventId] -> ShowS
GetTonConnectSessionNextEventId -> String
(Int -> GetTonConnectSessionNextEventId -> ShowS)
-> (GetTonConnectSessionNextEventId -> String)
-> ([GetTonConnectSessionNextEventId] -> ShowS)
-> Show GetTonConnectSessionNextEventId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTonConnectSessionNextEventId -> ShowS
showsPrec :: Int -> GetTonConnectSessionNextEventId -> ShowS
$cshow :: GetTonConnectSessionNextEventId -> String
show :: GetTonConnectSessionNextEventId -> String
$cshowList :: [GetTonConnectSessionNextEventId] -> ShowS
showList :: [GetTonConnectSessionNextEventId] -> ShowS
Show)

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

instance AT.ToJSON GetTonConnectSessionNextEventId where
  toJSON :: GetTonConnectSessionNextEventId -> Value
toJSON
    GetTonConnectSessionNextEventId
      { session_id :: GetTonConnectSessionNextEventId -> Maybe Int
session_id = Maybe Int
session_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
"getTonConnectSessionNextEventId"
          , Key
"session_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
session_id_
          ]