module TD.Data.ChatAdministrators
(ChatAdministrators(..)) 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.ChatAdministrator as ChatAdministrator
data ChatAdministrators
= ChatAdministrators
{ ChatAdministrators -> Maybe [ChatAdministrator]
administrators :: Maybe [ChatAdministrator.ChatAdministrator]
}
deriving (ChatAdministrators -> ChatAdministrators -> Bool
(ChatAdministrators -> ChatAdministrators -> Bool)
-> (ChatAdministrators -> ChatAdministrators -> Bool)
-> Eq ChatAdministrators
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatAdministrators -> ChatAdministrators -> Bool
== :: ChatAdministrators -> ChatAdministrators -> Bool
$c/= :: ChatAdministrators -> ChatAdministrators -> Bool
/= :: ChatAdministrators -> ChatAdministrators -> Bool
Eq, Int -> ChatAdministrators -> ShowS
[ChatAdministrators] -> ShowS
ChatAdministrators -> String
(Int -> ChatAdministrators -> ShowS)
-> (ChatAdministrators -> String)
-> ([ChatAdministrators] -> ShowS)
-> Show ChatAdministrators
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatAdministrators -> ShowS
showsPrec :: Int -> ChatAdministrators -> ShowS
$cshow :: ChatAdministrators -> String
show :: ChatAdministrators -> String
$cshowList :: [ChatAdministrators] -> ShowS
showList :: [ChatAdministrators] -> ShowS
Show)
instance I.ShortShow ChatAdministrators where
shortShow :: ChatAdministrators -> String
shortShow ChatAdministrators
{ administrators :: ChatAdministrators -> Maybe [ChatAdministrator]
administrators = Maybe [ChatAdministrator]
administrators_
}
= String
"ChatAdministrators"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"administrators" String -> Maybe [ChatAdministrator] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatAdministrator]
administrators_
]
instance AT.FromJSON ChatAdministrators where
parseJSON :: Value -> Parser ChatAdministrators
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
"chatAdministrators" -> Value -> Parser ChatAdministrators
parseChatAdministrators Value
v
String
_ -> Parser ChatAdministrators
forall a. Monoid a => a
mempty
where
parseChatAdministrators :: A.Value -> AT.Parser ChatAdministrators
parseChatAdministrators :: Value -> Parser ChatAdministrators
parseChatAdministrators = String
-> (Object -> Parser ChatAdministrators)
-> Value
-> Parser ChatAdministrators
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatAdministrators" ((Object -> Parser ChatAdministrators)
-> Value -> Parser ChatAdministrators)
-> (Object -> Parser ChatAdministrators)
-> Value
-> Parser ChatAdministrators
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [ChatAdministrator]
administrators_ <- Object
o Object -> Key -> Parser (Maybe [ChatAdministrator])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"administrators"
ChatAdministrators -> Parser ChatAdministrators
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatAdministrators -> Parser ChatAdministrators)
-> ChatAdministrators -> Parser ChatAdministrators
forall a b. (a -> b) -> a -> b
$ ChatAdministrators
{ administrators :: Maybe [ChatAdministrator]
administrators = Maybe [ChatAdministrator]
administrators_
}
parseJSON Value
_ = Parser ChatAdministrators
forall a. Monoid a => a
mempty