module TD.Data.ChatJoinRequestResult
(ChatJoinRequestResult(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ChatJoinRequestResult
= ChatJoinRequestResultApproved
| ChatJoinRequestResultDeclined
| ChatJoinRequestResultQueued
deriving (ChatJoinRequestResult -> ChatJoinRequestResult -> Bool
(ChatJoinRequestResult -> ChatJoinRequestResult -> Bool)
-> (ChatJoinRequestResult -> ChatJoinRequestResult -> Bool)
-> Eq ChatJoinRequestResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatJoinRequestResult -> ChatJoinRequestResult -> Bool
== :: ChatJoinRequestResult -> ChatJoinRequestResult -> Bool
$c/= :: ChatJoinRequestResult -> ChatJoinRequestResult -> Bool
/= :: ChatJoinRequestResult -> ChatJoinRequestResult -> Bool
Eq, Int -> ChatJoinRequestResult -> ShowS
[ChatJoinRequestResult] -> ShowS
ChatJoinRequestResult -> String
(Int -> ChatJoinRequestResult -> ShowS)
-> (ChatJoinRequestResult -> String)
-> ([ChatJoinRequestResult] -> ShowS)
-> Show ChatJoinRequestResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatJoinRequestResult -> ShowS
showsPrec :: Int -> ChatJoinRequestResult -> ShowS
$cshow :: ChatJoinRequestResult -> String
show :: ChatJoinRequestResult -> String
$cshowList :: [ChatJoinRequestResult] -> ShowS
showList :: [ChatJoinRequestResult] -> ShowS
Show)
instance I.ShortShow ChatJoinRequestResult where
shortShow :: ChatJoinRequestResult -> String
shortShow ChatJoinRequestResult
ChatJoinRequestResultApproved
= String
"ChatJoinRequestResultApproved"
shortShow ChatJoinRequestResult
ChatJoinRequestResultDeclined
= String
"ChatJoinRequestResultDeclined"
shortShow ChatJoinRequestResult
ChatJoinRequestResultQueued
= String
"ChatJoinRequestResultQueued"
instance AT.FromJSON ChatJoinRequestResult where
parseJSON :: Value -> Parser ChatJoinRequestResult
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
"chatJoinRequestResultApproved" -> ChatJoinRequestResult -> Parser ChatJoinRequestResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ChatJoinRequestResult
ChatJoinRequestResultApproved
String
"chatJoinRequestResultDeclined" -> ChatJoinRequestResult -> Parser ChatJoinRequestResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ChatJoinRequestResult
ChatJoinRequestResultDeclined
String
"chatJoinRequestResultQueued" -> ChatJoinRequestResult -> Parser ChatJoinRequestResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ChatJoinRequestResult
ChatJoinRequestResultQueued
String
_ -> Parser ChatJoinRequestResult
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser ChatJoinRequestResult
forall a. Monoid a => a
mempty
instance AT.ToJSON ChatJoinRequestResult where
toJSON :: ChatJoinRequestResult -> Value
toJSON ChatJoinRequestResult
ChatJoinRequestResultApproved
= [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
"chatJoinRequestResultApproved"
]
toJSON ChatJoinRequestResult
ChatJoinRequestResultDeclined
= [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
"chatJoinRequestResultDeclined"
]
toJSON ChatJoinRequestResult
ChatJoinRequestResultQueued
= [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
"chatJoinRequestResultQueued"
]