module TD.Data.WebBrowserType
(WebBrowserType(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data WebBrowserType
= WebBrowserTypeExternal
| WebBrowserTypeInApp
deriving (WebBrowserType -> WebBrowserType -> Bool
(WebBrowserType -> WebBrowserType -> Bool)
-> (WebBrowserType -> WebBrowserType -> Bool) -> Eq WebBrowserType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WebBrowserType -> WebBrowserType -> Bool
== :: WebBrowserType -> WebBrowserType -> Bool
$c/= :: WebBrowserType -> WebBrowserType -> Bool
/= :: WebBrowserType -> WebBrowserType -> Bool
Eq, Int -> WebBrowserType -> ShowS
[WebBrowserType] -> ShowS
WebBrowserType -> String
(Int -> WebBrowserType -> ShowS)
-> (WebBrowserType -> String)
-> ([WebBrowserType] -> ShowS)
-> Show WebBrowserType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WebBrowserType -> ShowS
showsPrec :: Int -> WebBrowserType -> ShowS
$cshow :: WebBrowserType -> String
show :: WebBrowserType -> String
$cshowList :: [WebBrowserType] -> ShowS
showList :: [WebBrowserType] -> ShowS
Show)
instance I.ShortShow WebBrowserType where
shortShow :: WebBrowserType -> String
shortShow WebBrowserType
WebBrowserTypeExternal
= String
"WebBrowserTypeExternal"
shortShow WebBrowserType
WebBrowserTypeInApp
= String
"WebBrowserTypeInApp"
instance AT.FromJSON WebBrowserType where
parseJSON :: Value -> Parser WebBrowserType
parseJSON (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
"webBrowserTypeExternal" -> WebBrowserType -> Parser WebBrowserType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure WebBrowserType
WebBrowserTypeExternal
String
"webBrowserTypeInApp" -> WebBrowserType -> Parser WebBrowserType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure WebBrowserType
WebBrowserTypeInApp
String
_ -> Parser WebBrowserType
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser WebBrowserType
forall a. Monoid a => a
mempty