module TD.Data.StoryVideo
(StoryVideo(..)) 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.Minithumbnail as Minithumbnail
import qualified TD.Data.Thumbnail as Thumbnail
import qualified TD.Data.File as File
data StoryVideo
= StoryVideo
{ StoryVideo -> Maybe Double
duration :: Maybe Double
, StoryVideo -> Maybe Int
width :: Maybe Int
, StoryVideo -> Maybe Int
height :: Maybe Int
, StoryVideo -> Maybe Bool
has_stickers :: Maybe Bool
, StoryVideo -> Maybe Bool
is_animation :: Maybe Bool
, StoryVideo -> Maybe Minithumbnail
minithumbnail :: Maybe Minithumbnail.Minithumbnail
, StoryVideo -> Maybe Thumbnail
thumbnail :: Maybe Thumbnail.Thumbnail
, StoryVideo -> Maybe Int
preload_prefix_size :: Maybe Int
, StoryVideo -> Maybe Double
cover_frame_timestamp :: Maybe Double
, StoryVideo -> Maybe File
video :: Maybe File.File
}
deriving (StoryVideo -> StoryVideo -> Bool
(StoryVideo -> StoryVideo -> Bool)
-> (StoryVideo -> StoryVideo -> Bool) -> Eq StoryVideo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StoryVideo -> StoryVideo -> Bool
== :: StoryVideo -> StoryVideo -> Bool
$c/= :: StoryVideo -> StoryVideo -> Bool
/= :: StoryVideo -> StoryVideo -> Bool
Eq, Int -> StoryVideo -> ShowS
[StoryVideo] -> ShowS
StoryVideo -> String
(Int -> StoryVideo -> ShowS)
-> (StoryVideo -> String)
-> ([StoryVideo] -> ShowS)
-> Show StoryVideo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StoryVideo -> ShowS
showsPrec :: Int -> StoryVideo -> ShowS
$cshow :: StoryVideo -> String
show :: StoryVideo -> String
$cshowList :: [StoryVideo] -> ShowS
showList :: [StoryVideo] -> ShowS
Show)
instance I.ShortShow StoryVideo where
shortShow :: StoryVideo -> String
shortShow StoryVideo
{ duration :: StoryVideo -> Maybe Double
duration = Maybe Double
duration_
, width :: StoryVideo -> Maybe Int
width = Maybe Int
width_
, height :: StoryVideo -> Maybe Int
height = Maybe Int
height_
, has_stickers :: StoryVideo -> Maybe Bool
has_stickers = Maybe Bool
has_stickers_
, is_animation :: StoryVideo -> Maybe Bool
is_animation = Maybe Bool
is_animation_
, minithumbnail :: StoryVideo -> Maybe Minithumbnail
minithumbnail = Maybe Minithumbnail
minithumbnail_
, thumbnail :: StoryVideo -> Maybe Thumbnail
thumbnail = Maybe Thumbnail
thumbnail_
, preload_prefix_size :: StoryVideo -> Maybe Int
preload_prefix_size = Maybe Int
preload_prefix_size_
, cover_frame_timestamp :: StoryVideo -> Maybe Double
cover_frame_timestamp = Maybe Double
cover_frame_timestamp_
, video :: StoryVideo -> Maybe File
video = Maybe File
video_
}
= String
"StoryVideo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"duration" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
duration_
, String
"width" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
width_
, String
"height" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
height_
, String
"has_stickers" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_stickers_
, String
"is_animation" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_animation_
, String
"minithumbnail" String -> Maybe Minithumbnail -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Minithumbnail
minithumbnail_
, String
"thumbnail" String -> Maybe Thumbnail -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Thumbnail
thumbnail_
, String
"preload_prefix_size" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
preload_prefix_size_
, String
"cover_frame_timestamp" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
cover_frame_timestamp_
, String
"video" String -> Maybe File -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe File
video_
]
instance AT.FromJSON StoryVideo where
parseJSON :: Value -> Parser StoryVideo
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
"storyVideo" -> Value -> Parser StoryVideo
parseStoryVideo Value
v
String
_ -> Parser StoryVideo
forall a. Monoid a => a
mempty
where
parseStoryVideo :: A.Value -> AT.Parser StoryVideo
parseStoryVideo :: Value -> Parser StoryVideo
parseStoryVideo = String
-> (Object -> Parser StoryVideo) -> Value -> Parser StoryVideo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StoryVideo" ((Object -> Parser StoryVideo) -> Value -> Parser StoryVideo)
-> (Object -> Parser StoryVideo) -> Value -> Parser StoryVideo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Double
duration_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"duration"
Maybe Int
width_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"width"
Maybe Int
height_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"height"
Maybe Bool
has_stickers_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_stickers"
Maybe Bool
is_animation_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_animation"
Maybe Minithumbnail
minithumbnail_ <- Object
o Object -> Key -> Parser (Maybe Minithumbnail)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"minithumbnail"
Maybe Thumbnail
thumbnail_ <- Object
o Object -> Key -> Parser (Maybe Thumbnail)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"thumbnail"
Maybe Int
preload_prefix_size_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"preload_prefix_size"
Maybe Double
cover_frame_timestamp_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"cover_frame_timestamp"
Maybe File
video_ <- Object
o Object -> Key -> Parser (Maybe File)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"video"
StoryVideo -> Parser StoryVideo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StoryVideo -> Parser StoryVideo)
-> StoryVideo -> Parser StoryVideo
forall a b. (a -> b) -> a -> b
$ StoryVideo
{ duration :: Maybe Double
duration = Maybe Double
duration_
, width :: Maybe Int
width = Maybe Int
width_
, height :: Maybe Int
height = Maybe Int
height_
, has_stickers :: Maybe Bool
has_stickers = Maybe Bool
has_stickers_
, is_animation :: Maybe Bool
is_animation = Maybe Bool
is_animation_
, minithumbnail :: Maybe Minithumbnail
minithumbnail = Maybe Minithumbnail
minithumbnail_
, thumbnail :: Maybe Thumbnail
thumbnail = Maybe Thumbnail
thumbnail_
, preload_prefix_size :: Maybe Int
preload_prefix_size = Maybe Int
preload_prefix_size_
, cover_frame_timestamp :: Maybe Double
cover_frame_timestamp = Maybe Double
cover_frame_timestamp_
, video :: Maybe File
video = Maybe File
video_
}
parseJSON Value
_ = Parser StoryVideo
forall a. Monoid a => a
mempty