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