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