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