module TD.Data.BasicGroupFullInfo
(BasicGroupFullInfo(..)) 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.ChatPhoto as ChatPhoto
import qualified Data.Text as T
import qualified TD.Data.ChatMember as ChatMember
import qualified TD.Data.ChatInviteLink as ChatInviteLink
import qualified TD.Data.BotCommands as BotCommands
data BasicGroupFullInfo
= BasicGroupFullInfo
{ BasicGroupFullInfo -> Maybe ChatPhoto
photo :: Maybe ChatPhoto.ChatPhoto
, BasicGroupFullInfo -> Maybe Text
description :: Maybe T.Text
, BasicGroupFullInfo -> Maybe Int
creator_user_id :: Maybe Int
, BasicGroupFullInfo -> Maybe [ChatMember]
members :: Maybe [ChatMember.ChatMember]
, BasicGroupFullInfo -> Maybe Bool
can_hide_members :: Maybe Bool
, BasicGroupFullInfo -> Maybe Bool
can_toggle_aggressive_anti_spam :: Maybe Bool
, BasicGroupFullInfo -> Maybe ChatInviteLink
invite_link :: Maybe ChatInviteLink.ChatInviteLink
, BasicGroupFullInfo -> Maybe [BotCommands]
bot_commands :: Maybe [BotCommands.BotCommands]
}
deriving (BasicGroupFullInfo -> BasicGroupFullInfo -> Bool
(BasicGroupFullInfo -> BasicGroupFullInfo -> Bool)
-> (BasicGroupFullInfo -> BasicGroupFullInfo -> Bool)
-> Eq BasicGroupFullInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BasicGroupFullInfo -> BasicGroupFullInfo -> Bool
== :: BasicGroupFullInfo -> BasicGroupFullInfo -> Bool
$c/= :: BasicGroupFullInfo -> BasicGroupFullInfo -> Bool
/= :: BasicGroupFullInfo -> BasicGroupFullInfo -> Bool
Eq, Int -> BasicGroupFullInfo -> ShowS
[BasicGroupFullInfo] -> ShowS
BasicGroupFullInfo -> String
(Int -> BasicGroupFullInfo -> ShowS)
-> (BasicGroupFullInfo -> String)
-> ([BasicGroupFullInfo] -> ShowS)
-> Show BasicGroupFullInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BasicGroupFullInfo -> ShowS
showsPrec :: Int -> BasicGroupFullInfo -> ShowS
$cshow :: BasicGroupFullInfo -> String
show :: BasicGroupFullInfo -> String
$cshowList :: [BasicGroupFullInfo] -> ShowS
showList :: [BasicGroupFullInfo] -> ShowS
Show)
instance I.ShortShow BasicGroupFullInfo where
shortShow :: BasicGroupFullInfo -> String
shortShow BasicGroupFullInfo
{ photo :: BasicGroupFullInfo -> Maybe ChatPhoto
photo = Maybe ChatPhoto
photo_
, description :: BasicGroupFullInfo -> Maybe Text
description = Maybe Text
description_
, creator_user_id :: BasicGroupFullInfo -> Maybe Int
creator_user_id = Maybe Int
creator_user_id_
, members :: BasicGroupFullInfo -> Maybe [ChatMember]
members = Maybe [ChatMember]
members_
, can_hide_members :: BasicGroupFullInfo -> Maybe Bool
can_hide_members = Maybe Bool
can_hide_members_
, can_toggle_aggressive_anti_spam :: BasicGroupFullInfo -> Maybe Bool
can_toggle_aggressive_anti_spam = Maybe Bool
can_toggle_aggressive_anti_spam_
, invite_link :: BasicGroupFullInfo -> Maybe ChatInviteLink
invite_link = Maybe ChatInviteLink
invite_link_
, bot_commands :: BasicGroupFullInfo -> Maybe [BotCommands]
bot_commands = Maybe [BotCommands]
bot_commands_
}
= String
"BasicGroupFullInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"photo" String -> Maybe ChatPhoto -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatPhoto
photo_
, String
"description" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
description_
, String
"creator_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
creator_user_id_
, String
"members" String -> Maybe [ChatMember] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatMember]
members_
, String
"can_hide_members" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_hide_members_
, String
"can_toggle_aggressive_anti_spam" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_toggle_aggressive_anti_spam_
, String
"invite_link" String -> Maybe ChatInviteLink -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatInviteLink
invite_link_
, String
"bot_commands" String -> Maybe [BotCommands] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [BotCommands]
bot_commands_
]
instance AT.FromJSON BasicGroupFullInfo where
parseJSON :: Value -> Parser BasicGroupFullInfo
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
"basicGroupFullInfo" -> Value -> Parser BasicGroupFullInfo
parseBasicGroupFullInfo Value
v
String
_ -> Parser BasicGroupFullInfo
forall a. Monoid a => a
mempty
where
parseBasicGroupFullInfo :: A.Value -> AT.Parser BasicGroupFullInfo
parseBasicGroupFullInfo :: Value -> Parser BasicGroupFullInfo
parseBasicGroupFullInfo = String
-> (Object -> Parser BasicGroupFullInfo)
-> Value
-> Parser BasicGroupFullInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BasicGroupFullInfo" ((Object -> Parser BasicGroupFullInfo)
-> Value -> Parser BasicGroupFullInfo)
-> (Object -> Parser BasicGroupFullInfo)
-> Value
-> Parser BasicGroupFullInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe ChatPhoto
photo_ <- Object
o Object -> Key -> Parser (Maybe ChatPhoto)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"photo"
Maybe Text
description_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"description"
Maybe Int
creator_user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"creator_user_id"
Maybe [ChatMember]
members_ <- Object
o Object -> Key -> Parser (Maybe [ChatMember])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"members"
Maybe Bool
can_hide_members_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_hide_members"
Maybe Bool
can_toggle_aggressive_anti_spam_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_toggle_aggressive_anti_spam"
Maybe ChatInviteLink
invite_link_ <- Object
o Object -> Key -> Parser (Maybe ChatInviteLink)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"invite_link"
Maybe [BotCommands]
bot_commands_ <- Object
o Object -> Key -> Parser (Maybe [BotCommands])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"bot_commands"
BasicGroupFullInfo -> Parser BasicGroupFullInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BasicGroupFullInfo -> Parser BasicGroupFullInfo)
-> BasicGroupFullInfo -> Parser BasicGroupFullInfo
forall a b. (a -> b) -> a -> b
$ BasicGroupFullInfo
{ photo :: Maybe ChatPhoto
photo = Maybe ChatPhoto
photo_
, description :: Maybe Text
description = Maybe Text
description_
, creator_user_id :: Maybe Int
creator_user_id = Maybe Int
creator_user_id_
, members :: Maybe [ChatMember]
members = Maybe [ChatMember]
members_
, can_hide_members :: Maybe Bool
can_hide_members = Maybe Bool
can_hide_members_
, can_toggle_aggressive_anti_spam :: Maybe Bool
can_toggle_aggressive_anti_spam = Maybe Bool
can_toggle_aggressive_anti_spam_
, invite_link :: Maybe ChatInviteLink
invite_link = Maybe ChatInviteLink
invite_link_
, bot_commands :: Maybe [BotCommands]
bot_commands = Maybe [BotCommands]
bot_commands_
}
parseJSON Value
_ = Parser BasicGroupFullInfo
forall a. Monoid a => a
mempty