module TD.Query.ConfirmSession
  (ConfirmSession(..)
  ) where

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

-- | Confirms an unconfirmed session of the current user from another device. Returns 'TD.Data.Ok.Ok'
data ConfirmSession
  = ConfirmSession
    { ConfirmSession -> Maybe Int
session_id :: Maybe Int -- ^ Session identifier
    }
  deriving (ConfirmSession -> ConfirmSession -> Bool
(ConfirmSession -> ConfirmSession -> Bool)
-> (ConfirmSession -> ConfirmSession -> Bool) -> Eq ConfirmSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConfirmSession -> ConfirmSession -> Bool
== :: ConfirmSession -> ConfirmSession -> Bool
$c/= :: ConfirmSession -> ConfirmSession -> Bool
/= :: ConfirmSession -> ConfirmSession -> Bool
Eq, Int -> ConfirmSession -> ShowS
[ConfirmSession] -> ShowS
ConfirmSession -> String
(Int -> ConfirmSession -> ShowS)
-> (ConfirmSession -> String)
-> ([ConfirmSession] -> ShowS)
-> Show ConfirmSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConfirmSession -> ShowS
showsPrec :: Int -> ConfirmSession -> ShowS
$cshow :: ConfirmSession -> String
show :: ConfirmSession -> String
$cshowList :: [ConfirmSession] -> ShowS
showList :: [ConfirmSession] -> ShowS
Show)

instance I.ShortShow ConfirmSession where
  shortShow :: ConfirmSession -> String
shortShow
    ConfirmSession
      { session_id :: ConfirmSession -> Maybe Int
session_id = Maybe Int
session_id_
      }
        = String
"ConfirmSession"
          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 ConfirmSession where
  toJSON :: ConfirmSession -> Value
toJSON
    ConfirmSession
      { session_id :: ConfirmSession -> 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
"confirmSession"
          , 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_
          ]