module TD.Data.ForumTopicInfo
(ForumTopicInfo(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.ForumTopicIcon as ForumTopicIcon
import qualified TD.Data.MessageSender as MessageSender
data ForumTopicInfo
= ForumTopicInfo
{ ForumTopicInfo -> Maybe Int
message_thread_id :: Maybe Int
, ForumTopicInfo -> Maybe Text
name :: Maybe T.Text
, ForumTopicInfo -> Maybe ForumTopicIcon
icon :: Maybe ForumTopicIcon.ForumTopicIcon
, ForumTopicInfo -> Maybe Int
creation_date :: Maybe Int
, ForumTopicInfo -> Maybe MessageSender
creator_id :: Maybe MessageSender.MessageSender
, ForumTopicInfo -> Maybe Bool
is_general :: Maybe Bool
, ForumTopicInfo -> Maybe Bool
is_outgoing :: Maybe Bool
, ForumTopicInfo -> Maybe Bool
is_closed :: Maybe Bool
, ForumTopicInfo -> Maybe Bool
is_hidden :: Maybe Bool
}
deriving (ForumTopicInfo -> ForumTopicInfo -> Bool
(ForumTopicInfo -> ForumTopicInfo -> Bool)
-> (ForumTopicInfo -> ForumTopicInfo -> Bool) -> Eq ForumTopicInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ForumTopicInfo -> ForumTopicInfo -> Bool
== :: ForumTopicInfo -> ForumTopicInfo -> Bool
$c/= :: ForumTopicInfo -> ForumTopicInfo -> Bool
/= :: ForumTopicInfo -> ForumTopicInfo -> Bool
Eq, Int -> ForumTopicInfo -> ShowS
[ForumTopicInfo] -> ShowS
ForumTopicInfo -> String
(Int -> ForumTopicInfo -> ShowS)
-> (ForumTopicInfo -> String)
-> ([ForumTopicInfo] -> ShowS)
-> Show ForumTopicInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ForumTopicInfo -> ShowS
showsPrec :: Int -> ForumTopicInfo -> ShowS
$cshow :: ForumTopicInfo -> String
show :: ForumTopicInfo -> String
$cshowList :: [ForumTopicInfo] -> ShowS
showList :: [ForumTopicInfo] -> ShowS
Show)
instance I.ShortShow ForumTopicInfo where
shortShow :: ForumTopicInfo -> String
shortShow ForumTopicInfo
{ message_thread_id :: ForumTopicInfo -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
, name :: ForumTopicInfo -> Maybe Text
name = Maybe Text
name_
, icon :: ForumTopicInfo -> Maybe ForumTopicIcon
icon = Maybe ForumTopicIcon
icon_
, creation_date :: ForumTopicInfo -> Maybe Int
creation_date = Maybe Int
creation_date_
, creator_id :: ForumTopicInfo -> Maybe MessageSender
creator_id = Maybe MessageSender
creator_id_
, is_general :: ForumTopicInfo -> Maybe Bool
is_general = Maybe Bool
is_general_
, is_outgoing :: ForumTopicInfo -> Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, is_closed :: ForumTopicInfo -> Maybe Bool
is_closed = Maybe Bool
is_closed_
, is_hidden :: ForumTopicInfo -> Maybe Bool
is_hidden = Maybe Bool
is_hidden_
}
= String
"ForumTopicInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"message_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
, String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
, String
"icon" String -> Maybe ForumTopicIcon -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ForumTopicIcon
icon_
, String
"creation_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
creation_date_
, String
"creator_id" String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
creator_id_
, String
"is_general" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_general_
, String
"is_outgoing" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_outgoing_
, String
"is_closed" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_closed_
, String
"is_hidden" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_hidden_
]
instance AT.FromJSON ForumTopicInfo where
parseJSON :: Value -> Parser ForumTopicInfo
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
"forumTopicInfo" -> Value -> Parser ForumTopicInfo
parseForumTopicInfo Value
v
String
_ -> Parser ForumTopicInfo
forall a. Monoid a => a
mempty
where
parseForumTopicInfo :: A.Value -> AT.Parser ForumTopicInfo
parseForumTopicInfo :: Value -> Parser ForumTopicInfo
parseForumTopicInfo = String
-> (Object -> Parser ForumTopicInfo)
-> Value
-> Parser ForumTopicInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ForumTopicInfo" ((Object -> Parser ForumTopicInfo)
-> Value -> Parser ForumTopicInfo)
-> (Object -> Parser ForumTopicInfo)
-> Value
-> Parser ForumTopicInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
message_thread_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"message_thread_id"
Maybe Text
name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"name"
Maybe ForumTopicIcon
icon_ <- Object
o Object -> Key -> Parser (Maybe ForumTopicIcon)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"icon"
Maybe Int
creation_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"creation_date"
Maybe MessageSender
creator_id_ <- Object
o Object -> Key -> Parser (Maybe MessageSender)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"creator_id"
Maybe Bool
is_general_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_general"
Maybe Bool
is_outgoing_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_outgoing"
Maybe Bool
is_closed_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_closed"
Maybe Bool
is_hidden_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_hidden"
ForumTopicInfo -> Parser ForumTopicInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ForumTopicInfo -> Parser ForumTopicInfo)
-> ForumTopicInfo -> Parser ForumTopicInfo
forall a b. (a -> b) -> a -> b
$ ForumTopicInfo
{ message_thread_id :: Maybe Int
message_thread_id = Maybe Int
message_thread_id_
, name :: Maybe Text
name = Maybe Text
name_
, icon :: Maybe ForumTopicIcon
icon = Maybe ForumTopicIcon
icon_
, creation_date :: Maybe Int
creation_date = Maybe Int
creation_date_
, creator_id :: Maybe MessageSender
creator_id = Maybe MessageSender
creator_id_
, is_general :: Maybe Bool
is_general = Maybe Bool
is_general_
, is_outgoing :: Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, is_closed :: Maybe Bool
is_closed = Maybe Bool
is_closed_
, is_hidden :: Maybe Bool
is_hidden = Maybe Bool
is_hidden_
}
parseJSON Value
_ = Parser ForumTopicInfo
forall a. Monoid a => a
mempty