module TD.Data.Supergroup
(Supergroup(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.Usernames as Usernames
import qualified TD.Data.ChatMemberStatus as ChatMemberStatus
import qualified TD.Data.VerificationStatus as VerificationStatus
import qualified Data.Text as T
data Supergroup
= Supergroup
{ Supergroup -> Maybe Int
_id :: Maybe Int
, Supergroup -> Maybe Usernames
usernames :: Maybe Usernames.Usernames
, Supergroup -> Maybe Int
date :: Maybe Int
, Supergroup -> Maybe ChatMemberStatus
status :: Maybe ChatMemberStatus.ChatMemberStatus
, Supergroup -> Maybe Int
member_count :: Maybe Int
, Supergroup -> Maybe Int
boost_level :: Maybe Int
, Supergroup -> Maybe Bool
has_linked_chat :: Maybe Bool
, Supergroup -> Maybe Bool
has_location :: Maybe Bool
, Supergroup -> Maybe Bool
sign_messages :: Maybe Bool
, Supergroup -> Maybe Bool
show_message_sender :: Maybe Bool
, Supergroup -> Maybe Bool
join_to_send_messages :: Maybe Bool
, Supergroup -> Maybe Bool
join_by_request :: Maybe Bool
, Supergroup -> Maybe Bool
is_slow_mode_enabled :: Maybe Bool
, Supergroup -> Maybe Bool
is_channel :: Maybe Bool
, Supergroup -> Maybe Bool
is_broadcast_group :: Maybe Bool
, Supergroup -> Maybe Bool
is_forum :: Maybe Bool
, Supergroup -> Maybe VerificationStatus
verification_status :: Maybe VerificationStatus.VerificationStatus
, Supergroup -> Maybe Bool
has_sensitive_content :: Maybe Bool
, Supergroup -> Maybe Text
restriction_reason :: Maybe T.Text
, Supergroup -> Maybe Bool
has_active_stories :: Maybe Bool
, Supergroup -> Maybe Bool
has_unread_active_stories :: Maybe Bool
}
deriving (Supergroup -> Supergroup -> Bool
(Supergroup -> Supergroup -> Bool)
-> (Supergroup -> Supergroup -> Bool) -> Eq Supergroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Supergroup -> Supergroup -> Bool
== :: Supergroup -> Supergroup -> Bool
$c/= :: Supergroup -> Supergroup -> Bool
/= :: Supergroup -> Supergroup -> Bool
Eq, Int -> Supergroup -> ShowS
[Supergroup] -> ShowS
Supergroup -> String
(Int -> Supergroup -> ShowS)
-> (Supergroup -> String)
-> ([Supergroup] -> ShowS)
-> Show Supergroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Supergroup -> ShowS
showsPrec :: Int -> Supergroup -> ShowS
$cshow :: Supergroup -> String
show :: Supergroup -> String
$cshowList :: [Supergroup] -> ShowS
showList :: [Supergroup] -> ShowS
Show)
instance I.ShortShow Supergroup where
shortShow :: Supergroup -> String
shortShow Supergroup
{ _id :: Supergroup -> Maybe Int
_id = Maybe Int
_id_
, usernames :: Supergroup -> Maybe Usernames
usernames = Maybe Usernames
usernames_
, date :: Supergroup -> Maybe Int
date = Maybe Int
date_
, status :: Supergroup -> Maybe ChatMemberStatus
status = Maybe ChatMemberStatus
status_
, member_count :: Supergroup -> Maybe Int
member_count = Maybe Int
member_count_
, boost_level :: Supergroup -> Maybe Int
boost_level = Maybe Int
boost_level_
, has_linked_chat :: Supergroup -> Maybe Bool
has_linked_chat = Maybe Bool
has_linked_chat_
, has_location :: Supergroup -> Maybe Bool
has_location = Maybe Bool
has_location_
, sign_messages :: Supergroup -> Maybe Bool
sign_messages = Maybe Bool
sign_messages_
, show_message_sender :: Supergroup -> Maybe Bool
show_message_sender = Maybe Bool
show_message_sender_
, join_to_send_messages :: Supergroup -> Maybe Bool
join_to_send_messages = Maybe Bool
join_to_send_messages_
, join_by_request :: Supergroup -> Maybe Bool
join_by_request = Maybe Bool
join_by_request_
, is_slow_mode_enabled :: Supergroup -> Maybe Bool
is_slow_mode_enabled = Maybe Bool
is_slow_mode_enabled_
, is_channel :: Supergroup -> Maybe Bool
is_channel = Maybe Bool
is_channel_
, is_broadcast_group :: Supergroup -> Maybe Bool
is_broadcast_group = Maybe Bool
is_broadcast_group_
, is_forum :: Supergroup -> Maybe Bool
is_forum = Maybe Bool
is_forum_
, verification_status :: Supergroup -> Maybe VerificationStatus
verification_status = Maybe VerificationStatus
verification_status_
, has_sensitive_content :: Supergroup -> Maybe Bool
has_sensitive_content = Maybe Bool
has_sensitive_content_
, restriction_reason :: Supergroup -> Maybe Text
restriction_reason = Maybe Text
restriction_reason_
, has_active_stories :: Supergroup -> Maybe Bool
has_active_stories = Maybe Bool
has_active_stories_
, has_unread_active_stories :: Supergroup -> Maybe Bool
has_unread_active_stories = Maybe Bool
has_unread_active_stories_
}
= String
"Supergroup"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
_id_
, String
"usernames" String -> Maybe Usernames -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Usernames
usernames_
, String
"date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
date_
, String
"status" String -> Maybe ChatMemberStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatMemberStatus
status_
, String
"member_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
member_count_
, String
"boost_level" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
boost_level_
, String
"has_linked_chat" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_linked_chat_
, String
"has_location" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_location_
, String
"sign_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
sign_messages_
, String
"show_message_sender" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
show_message_sender_
, String
"join_to_send_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
join_to_send_messages_
, String
"join_by_request" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
join_by_request_
, String
"is_slow_mode_enabled" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_slow_mode_enabled_
, String
"is_channel" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_channel_
, String
"is_broadcast_group" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_broadcast_group_
, String
"is_forum" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_forum_
, String
"verification_status" String -> Maybe VerificationStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe VerificationStatus
verification_status_
, String
"has_sensitive_content" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_sensitive_content_
, String
"restriction_reason" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
restriction_reason_
, String
"has_active_stories" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_active_stories_
, String
"has_unread_active_stories" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_unread_active_stories_
]
instance AT.FromJSON Supergroup where
parseJSON :: Value -> Parser Supergroup
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
"supergroup" -> Value -> Parser Supergroup
parseSupergroup Value
v
String
_ -> Parser Supergroup
forall a. Monoid a => a
mempty
where
parseSupergroup :: A.Value -> AT.Parser Supergroup
parseSupergroup :: Value -> Parser Supergroup
parseSupergroup = String
-> (Object -> Parser Supergroup) -> Value -> Parser Supergroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"Supergroup" ((Object -> Parser Supergroup) -> Value -> Parser Supergroup)
-> (Object -> Parser Supergroup) -> Value -> Parser Supergroup
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe Usernames
usernames_ <- Object
o Object -> Key -> Parser (Maybe Usernames)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"usernames"
Maybe Int
date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"date"
Maybe ChatMemberStatus
status_ <- Object
o Object -> Key -> Parser (Maybe ChatMemberStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"status"
Maybe Int
member_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"member_count"
Maybe Int
boost_level_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"boost_level"
Maybe Bool
has_linked_chat_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_linked_chat"
Maybe Bool
has_location_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_location"
Maybe Bool
sign_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sign_messages"
Maybe Bool
show_message_sender_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"show_message_sender"
Maybe Bool
join_to_send_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"join_to_send_messages"
Maybe Bool
join_by_request_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"join_by_request"
Maybe Bool
is_slow_mode_enabled_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_slow_mode_enabled"
Maybe Bool
is_channel_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_channel"
Maybe Bool
is_broadcast_group_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_broadcast_group"
Maybe Bool
is_forum_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_forum"
Maybe VerificationStatus
verification_status_ <- Object
o Object -> Key -> Parser (Maybe VerificationStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"verification_status"
Maybe Bool
has_sensitive_content_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_sensitive_content"
Maybe Text
restriction_reason_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"restriction_reason"
Maybe Bool
has_active_stories_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_active_stories"
Maybe Bool
has_unread_active_stories_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_unread_active_stories"
Supergroup -> Parser Supergroup
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Supergroup -> Parser Supergroup)
-> Supergroup -> Parser Supergroup
forall a b. (a -> b) -> a -> b
$ Supergroup
{ _id :: Maybe Int
_id = Maybe Int
_id_
, usernames :: Maybe Usernames
usernames = Maybe Usernames
usernames_
, date :: Maybe Int
date = Maybe Int
date_
, status :: Maybe ChatMemberStatus
status = Maybe ChatMemberStatus
status_
, member_count :: Maybe Int
member_count = Maybe Int
member_count_
, boost_level :: Maybe Int
boost_level = Maybe Int
boost_level_
, has_linked_chat :: Maybe Bool
has_linked_chat = Maybe Bool
has_linked_chat_
, has_location :: Maybe Bool
has_location = Maybe Bool
has_location_
, sign_messages :: Maybe Bool
sign_messages = Maybe Bool
sign_messages_
, show_message_sender :: Maybe Bool
show_message_sender = Maybe Bool
show_message_sender_
, join_to_send_messages :: Maybe Bool
join_to_send_messages = Maybe Bool
join_to_send_messages_
, join_by_request :: Maybe Bool
join_by_request = Maybe Bool
join_by_request_
, is_slow_mode_enabled :: Maybe Bool
is_slow_mode_enabled = Maybe Bool
is_slow_mode_enabled_
, is_channel :: Maybe Bool
is_channel = Maybe Bool
is_channel_
, is_broadcast_group :: Maybe Bool
is_broadcast_group = Maybe Bool
is_broadcast_group_
, is_forum :: Maybe Bool
is_forum = Maybe Bool
is_forum_
, verification_status :: Maybe VerificationStatus
verification_status = Maybe VerificationStatus
verification_status_
, has_sensitive_content :: Maybe Bool
has_sensitive_content = Maybe Bool
has_sensitive_content_
, restriction_reason :: Maybe Text
restriction_reason = Maybe Text
restriction_reason_
, has_active_stories :: Maybe Bool
has_active_stories = Maybe Bool
has_active_stories_
, has_unread_active_stories :: Maybe Bool
has_unread_active_stories = Maybe Bool
has_unread_active_stories_
}
parseJSON Value
_ = Parser Supergroup
forall a. Monoid a => a
mempty