module TD.Data.SecretChatState
(SecretChatState(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data SecretChatState
= SecretChatStatePending
| SecretChatStateReady
| SecretChatStateClosed
deriving (SecretChatState -> SecretChatState -> Bool
(SecretChatState -> SecretChatState -> Bool)
-> (SecretChatState -> SecretChatState -> Bool)
-> Eq SecretChatState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SecretChatState -> SecretChatState -> Bool
== :: SecretChatState -> SecretChatState -> Bool
$c/= :: SecretChatState -> SecretChatState -> Bool
/= :: SecretChatState -> SecretChatState -> Bool
Eq, Int -> SecretChatState -> ShowS
[SecretChatState] -> ShowS
SecretChatState -> String
(Int -> SecretChatState -> ShowS)
-> (SecretChatState -> String)
-> ([SecretChatState] -> ShowS)
-> Show SecretChatState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SecretChatState -> ShowS
showsPrec :: Int -> SecretChatState -> ShowS
$cshow :: SecretChatState -> String
show :: SecretChatState -> String
$cshowList :: [SecretChatState] -> ShowS
showList :: [SecretChatState] -> ShowS
Show)
instance I.ShortShow SecretChatState where
shortShow :: SecretChatState -> String
shortShow SecretChatState
SecretChatStatePending
= String
"SecretChatStatePending"
shortShow SecretChatState
SecretChatStateReady
= String
"SecretChatStateReady"
shortShow SecretChatState
SecretChatStateClosed
= String
"SecretChatStateClosed"
instance AT.FromJSON SecretChatState where
parseJSON :: Value -> Parser SecretChatState
parseJSON (AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"secretChatStatePending" -> SecretChatState -> Parser SecretChatState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SecretChatState
SecretChatStatePending
String
"secretChatStateReady" -> SecretChatState -> Parser SecretChatState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SecretChatState
SecretChatStateReady
String
"secretChatStateClosed" -> SecretChatState -> Parser SecretChatState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SecretChatState
SecretChatStateClosed
String
_ -> Parser SecretChatState
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser SecretChatState
forall a. Monoid a => a
mempty