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