module TD.Data.WebAppOpenMode
(WebAppOpenMode(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data WebAppOpenMode
= WebAppOpenModeCompact
| WebAppOpenModeFullSize
| WebAppOpenModeFullScreen
deriving (WebAppOpenMode -> WebAppOpenMode -> Bool
(WebAppOpenMode -> WebAppOpenMode -> Bool)
-> (WebAppOpenMode -> WebAppOpenMode -> Bool) -> Eq WebAppOpenMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WebAppOpenMode -> WebAppOpenMode -> Bool
== :: WebAppOpenMode -> WebAppOpenMode -> Bool
$c/= :: WebAppOpenMode -> WebAppOpenMode -> Bool
/= :: WebAppOpenMode -> WebAppOpenMode -> Bool
Eq, Int -> WebAppOpenMode -> ShowS
[WebAppOpenMode] -> ShowS
WebAppOpenMode -> String
(Int -> WebAppOpenMode -> ShowS)
-> (WebAppOpenMode -> String)
-> ([WebAppOpenMode] -> ShowS)
-> Show WebAppOpenMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WebAppOpenMode -> ShowS
showsPrec :: Int -> WebAppOpenMode -> ShowS
$cshow :: WebAppOpenMode -> String
show :: WebAppOpenMode -> String
$cshowList :: [WebAppOpenMode] -> ShowS
showList :: [WebAppOpenMode] -> ShowS
Show)
instance I.ShortShow WebAppOpenMode where
shortShow :: WebAppOpenMode -> String
shortShow WebAppOpenMode
WebAppOpenModeCompact
= String
"WebAppOpenModeCompact"
shortShow WebAppOpenMode
WebAppOpenModeFullSize
= String
"WebAppOpenModeFullSize"
shortShow WebAppOpenMode
WebAppOpenModeFullScreen
= String
"WebAppOpenModeFullScreen"
instance AT.FromJSON WebAppOpenMode where
parseJSON :: Value -> Parser WebAppOpenMode
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
"webAppOpenModeCompact" -> WebAppOpenMode -> Parser WebAppOpenMode
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure WebAppOpenMode
WebAppOpenModeCompact
String
"webAppOpenModeFullSize" -> WebAppOpenMode -> Parser WebAppOpenMode
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure WebAppOpenMode
WebAppOpenModeFullSize
String
"webAppOpenModeFullScreen" -> WebAppOpenMode -> Parser WebAppOpenMode
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure WebAppOpenMode
WebAppOpenModeFullScreen
String
_ -> Parser WebAppOpenMode
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser WebAppOpenMode
forall a. Monoid a => a
mempty
instance AT.ToJSON WebAppOpenMode where
toJSON :: WebAppOpenMode -> Value
toJSON WebAppOpenMode
WebAppOpenModeCompact
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"webAppOpenModeCompact"
]
toJSON WebAppOpenMode
WebAppOpenModeFullSize
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"webAppOpenModeFullSize"
]
toJSON WebAppOpenMode
WebAppOpenModeFullScreen
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"webAppOpenModeFullScreen"
]