module TD.Data.StartLiveStoryResult
(StartLiveStoryResult(..)) 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.Story as Story
import qualified TD.Data.CanPostStoryResult as CanPostStoryResult
data StartLiveStoryResult
= StartLiveStoryResultOk
{ StartLiveStoryResult -> Maybe Story
story :: Maybe Story.Story
}
| StartLiveStoryResultFail
{ StartLiveStoryResult -> Maybe CanPostStoryResult
error_type :: Maybe CanPostStoryResult.CanPostStoryResult
}
deriving (StartLiveStoryResult -> StartLiveStoryResult -> Bool
(StartLiveStoryResult -> StartLiveStoryResult -> Bool)
-> (StartLiveStoryResult -> StartLiveStoryResult -> Bool)
-> Eq StartLiveStoryResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StartLiveStoryResult -> StartLiveStoryResult -> Bool
== :: StartLiveStoryResult -> StartLiveStoryResult -> Bool
$c/= :: StartLiveStoryResult -> StartLiveStoryResult -> Bool
/= :: StartLiveStoryResult -> StartLiveStoryResult -> Bool
Eq, Int -> StartLiveStoryResult -> ShowS
[StartLiveStoryResult] -> ShowS
StartLiveStoryResult -> String
(Int -> StartLiveStoryResult -> ShowS)
-> (StartLiveStoryResult -> String)
-> ([StartLiveStoryResult] -> ShowS)
-> Show StartLiveStoryResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StartLiveStoryResult -> ShowS
showsPrec :: Int -> StartLiveStoryResult -> ShowS
$cshow :: StartLiveStoryResult -> String
show :: StartLiveStoryResult -> String
$cshowList :: [StartLiveStoryResult] -> ShowS
showList :: [StartLiveStoryResult] -> ShowS
Show)
instance I.ShortShow StartLiveStoryResult where
shortShow :: StartLiveStoryResult -> String
shortShow StartLiveStoryResultOk
{ story :: StartLiveStoryResult -> Maybe Story
story = Maybe Story
story_
}
= String
"StartLiveStoryResultOk"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"story" String -> Maybe Story -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Story
story_
]
shortShow StartLiveStoryResultFail
{ error_type :: StartLiveStoryResult -> Maybe CanPostStoryResult
error_type = Maybe CanPostStoryResult
error_type_
}
= String
"StartLiveStoryResultFail"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"error_type" String -> Maybe CanPostStoryResult -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe CanPostStoryResult
error_type_
]
instance AT.FromJSON StartLiveStoryResult where
parseJSON :: Value -> Parser StartLiveStoryResult
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
"startLiveStoryResultOk" -> Value -> Parser StartLiveStoryResult
parseStartLiveStoryResultOk Value
v
String
"startLiveStoryResultFail" -> Value -> Parser StartLiveStoryResult
parseStartLiveStoryResultFail Value
v
String
_ -> Parser StartLiveStoryResult
forall a. Monoid a => a
mempty
where
parseStartLiveStoryResultOk :: A.Value -> AT.Parser StartLiveStoryResult
parseStartLiveStoryResultOk :: Value -> Parser StartLiveStoryResult
parseStartLiveStoryResultOk = String
-> (Object -> Parser StartLiveStoryResult)
-> Value
-> Parser StartLiveStoryResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StartLiveStoryResultOk" ((Object -> Parser StartLiveStoryResult)
-> Value -> Parser StartLiveStoryResult)
-> (Object -> Parser StartLiveStoryResult)
-> Value
-> Parser StartLiveStoryResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Story
story_ <- Object
o Object -> Key -> Parser (Maybe Story)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"story"
StartLiveStoryResult -> Parser StartLiveStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StartLiveStoryResult -> Parser StartLiveStoryResult)
-> StartLiveStoryResult -> Parser StartLiveStoryResult
forall a b. (a -> b) -> a -> b
$ StartLiveStoryResultOk
{ story :: Maybe Story
story = Maybe Story
story_
}
parseStartLiveStoryResultFail :: A.Value -> AT.Parser StartLiveStoryResult
parseStartLiveStoryResultFail :: Value -> Parser StartLiveStoryResult
parseStartLiveStoryResultFail = String
-> (Object -> Parser StartLiveStoryResult)
-> Value
-> Parser StartLiveStoryResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StartLiveStoryResultFail" ((Object -> Parser StartLiveStoryResult)
-> Value -> Parser StartLiveStoryResult)
-> (Object -> Parser StartLiveStoryResult)
-> Value
-> Parser StartLiveStoryResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe CanPostStoryResult
error_type_ <- Object
o Object -> Key -> Parser (Maybe CanPostStoryResult)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"error_type"
StartLiveStoryResult -> Parser StartLiveStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StartLiveStoryResult -> Parser StartLiveStoryResult)
-> StartLiveStoryResult -> Parser StartLiveStoryResult
forall a b. (a -> b) -> a -> b
$ StartLiveStoryResultFail
{ error_type :: Maybe CanPostStoryResult
error_type = Maybe CanPostStoryResult
error_type_
}
parseJSON Value
_ = Parser StartLiveStoryResult
forall a. Monoid a => a
mempty