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