module TD.Data.SavedMessagesTopicType
(SavedMessagesTopicType(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data SavedMessagesTopicType
= SavedMessagesTopicTypeMyNotes
| SavedMessagesTopicTypeAuthorHidden
| SavedMessagesTopicTypeSavedFromChat
{ SavedMessagesTopicType -> Maybe Int
chat_id :: Maybe Int
}
deriving (SavedMessagesTopicType -> SavedMessagesTopicType -> Bool
(SavedMessagesTopicType -> SavedMessagesTopicType -> Bool)
-> (SavedMessagesTopicType -> SavedMessagesTopicType -> Bool)
-> Eq SavedMessagesTopicType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SavedMessagesTopicType -> SavedMessagesTopicType -> Bool
== :: SavedMessagesTopicType -> SavedMessagesTopicType -> Bool
$c/= :: SavedMessagesTopicType -> SavedMessagesTopicType -> Bool
/= :: SavedMessagesTopicType -> SavedMessagesTopicType -> Bool
Eq, Int -> SavedMessagesTopicType -> ShowS
[SavedMessagesTopicType] -> ShowS
SavedMessagesTopicType -> String
(Int -> SavedMessagesTopicType -> ShowS)
-> (SavedMessagesTopicType -> String)
-> ([SavedMessagesTopicType] -> ShowS)
-> Show SavedMessagesTopicType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SavedMessagesTopicType -> ShowS
showsPrec :: Int -> SavedMessagesTopicType -> ShowS
$cshow :: SavedMessagesTopicType -> String
show :: SavedMessagesTopicType -> String
$cshowList :: [SavedMessagesTopicType] -> ShowS
showList :: [SavedMessagesTopicType] -> ShowS
Show)
instance I.ShortShow SavedMessagesTopicType where
shortShow :: SavedMessagesTopicType -> String
shortShow SavedMessagesTopicType
SavedMessagesTopicTypeMyNotes
= String
"SavedMessagesTopicTypeMyNotes"
shortShow SavedMessagesTopicType
SavedMessagesTopicTypeAuthorHidden
= String
"SavedMessagesTopicTypeAuthorHidden"
shortShow SavedMessagesTopicTypeSavedFromChat
{ chat_id :: SavedMessagesTopicType -> Maybe Int
chat_id = Maybe Int
chat_id_
}
= String
"SavedMessagesTopicTypeSavedFromChat"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
]
instance AT.FromJSON SavedMessagesTopicType where
parseJSON :: Value -> Parser SavedMessagesTopicType
parseJSON v :: Value
v@(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
"savedMessagesTopicTypeMyNotes" -> SavedMessagesTopicType -> Parser SavedMessagesTopicType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SavedMessagesTopicType
SavedMessagesTopicTypeMyNotes
String
"savedMessagesTopicTypeAuthorHidden" -> SavedMessagesTopicType -> Parser SavedMessagesTopicType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SavedMessagesTopicType
SavedMessagesTopicTypeAuthorHidden
String
"savedMessagesTopicTypeSavedFromChat" -> Value -> Parser SavedMessagesTopicType
parseSavedMessagesTopicTypeSavedFromChat Value
v
String
_ -> Parser SavedMessagesTopicType
forall a. Monoid a => a
mempty
where
parseSavedMessagesTopicTypeSavedFromChat :: A.Value -> AT.Parser SavedMessagesTopicType
parseSavedMessagesTopicTypeSavedFromChat :: Value -> Parser SavedMessagesTopicType
parseSavedMessagesTopicTypeSavedFromChat = String
-> (Object -> Parser SavedMessagesTopicType)
-> Value
-> Parser SavedMessagesTopicType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SavedMessagesTopicTypeSavedFromChat" ((Object -> Parser SavedMessagesTopicType)
-> Value -> Parser SavedMessagesTopicType)
-> (Object -> Parser SavedMessagesTopicType)
-> Value
-> Parser SavedMessagesTopicType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_id"
SavedMessagesTopicType -> Parser SavedMessagesTopicType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SavedMessagesTopicType -> Parser SavedMessagesTopicType)
-> SavedMessagesTopicType -> Parser SavedMessagesTopicType
forall a b. (a -> b) -> a -> b
$ SavedMessagesTopicTypeSavedFromChat
{ chat_id :: Maybe Int
chat_id = Maybe Int
chat_id_
}
parseJSON Value
_ = Parser SavedMessagesTopicType
forall a. Monoid a => a
mempty