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