module TD.Data.CommunityAdministratorRights
(CommunityAdministratorRights(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data
=
{ :: Maybe Bool
, CommunityAdministratorRights -> Maybe Bool
can_change_info :: Maybe Bool
, CommunityAdministratorRights -> Maybe Bool
can_edit_chat_list :: Maybe Bool
, CommunityAdministratorRights -> Maybe Bool
can_promote_members :: Maybe Bool
, CommunityAdministratorRights -> Maybe Bool
can_ban_members :: Maybe Bool
}
deriving (CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool
(CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool)
-> (CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool)
-> Eq CommunityAdministratorRights
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool
== :: CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool
$c/= :: CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool
/= :: CommunityAdministratorRights
-> CommunityAdministratorRights -> Bool
Eq, Int -> CommunityAdministratorRights -> ShowS
[CommunityAdministratorRights] -> ShowS
CommunityAdministratorRights -> String
(Int -> CommunityAdministratorRights -> ShowS)
-> (CommunityAdministratorRights -> String)
-> ([CommunityAdministratorRights] -> ShowS)
-> Show CommunityAdministratorRights
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommunityAdministratorRights -> ShowS
showsPrec :: Int -> CommunityAdministratorRights -> ShowS
$cshow :: CommunityAdministratorRights -> String
show :: CommunityAdministratorRights -> String
$cshowList :: [CommunityAdministratorRights] -> ShowS
showList :: [CommunityAdministratorRights] -> ShowS
Show)
instance I.ShortShow CommunityAdministratorRights where
shortShow :: CommunityAdministratorRights -> String
shortShow CommunityAdministratorRights
{ can_manage_community :: CommunityAdministratorRights -> Maybe Bool
can_manage_community = Maybe Bool
can_manage_community_
, can_change_info :: CommunityAdministratorRights -> Maybe Bool
can_change_info = Maybe Bool
can_change_info_
, can_edit_chat_list :: CommunityAdministratorRights -> Maybe Bool
can_edit_chat_list = Maybe Bool
can_edit_chat_list_
, can_promote_members :: CommunityAdministratorRights -> Maybe Bool
can_promote_members = Maybe Bool
can_promote_members_
, can_ban_members :: CommunityAdministratorRights -> Maybe Bool
can_ban_members = Maybe Bool
can_ban_members_
}
= String
"CommunityAdministratorRights"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"can_manage_community" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_manage_community_
, String
"can_change_info" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_change_info_
, String
"can_edit_chat_list" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_edit_chat_list_
, String
"can_promote_members" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_promote_members_
, String
"can_ban_members" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_ban_members_
]
instance AT.FromJSON CommunityAdministratorRights where
parseJSON :: Value -> Parser CommunityAdministratorRights
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
"communityAdministratorRights" -> Value -> Parser CommunityAdministratorRights
parseCommunityAdministratorRights Value
v
String
_ -> Parser CommunityAdministratorRights
forall a. Monoid a => a
mempty
where
parseCommunityAdministratorRights :: A.Value -> AT.Parser CommunityAdministratorRights
parseCommunityAdministratorRights :: Value -> Parser CommunityAdministratorRights
parseCommunityAdministratorRights = String
-> (Object -> Parser CommunityAdministratorRights)
-> Value
-> Parser CommunityAdministratorRights
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CommunityAdministratorRights" ((Object -> Parser CommunityAdministratorRights)
-> Value -> Parser CommunityAdministratorRights)
-> (Object -> Parser CommunityAdministratorRights)
-> Value
-> Parser CommunityAdministratorRights
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
can_manage_community_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_manage_community"
Maybe Bool
can_change_info_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_change_info"
Maybe Bool
can_edit_chat_list_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_edit_chat_list"
Maybe Bool
can_promote_members_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_promote_members"
Maybe Bool
can_ban_members_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_ban_members"
CommunityAdministratorRights -> Parser CommunityAdministratorRights
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CommunityAdministratorRights
-> Parser CommunityAdministratorRights)
-> CommunityAdministratorRights
-> Parser CommunityAdministratorRights
forall a b. (a -> b) -> a -> b
$ CommunityAdministratorRights
{ can_manage_community :: Maybe Bool
can_manage_community = Maybe Bool
can_manage_community_
, can_change_info :: Maybe Bool
can_change_info = Maybe Bool
can_change_info_
, can_edit_chat_list :: Maybe Bool
can_edit_chat_list = Maybe Bool
can_edit_chat_list_
, can_promote_members :: Maybe Bool
can_promote_members = Maybe Bool
can_promote_members_
, can_ban_members :: Maybe Bool
can_ban_members = Maybe Bool
can_ban_members_
}
parseJSON Value
_ = Parser CommunityAdministratorRights
forall a. Monoid a => a
mempty