module TD.Data.AnimatedChatPhoto
(AnimatedChatPhoto(..)) 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.File as File
data AnimatedChatPhoto
= AnimatedChatPhoto
{ AnimatedChatPhoto -> Maybe Int
_length :: Maybe Int
, AnimatedChatPhoto -> Maybe File
file :: Maybe File.File
, AnimatedChatPhoto -> Maybe Double
main_frame_timestamp :: Maybe Double
}
deriving (AnimatedChatPhoto -> AnimatedChatPhoto -> Bool
(AnimatedChatPhoto -> AnimatedChatPhoto -> Bool)
-> (AnimatedChatPhoto -> AnimatedChatPhoto -> Bool)
-> Eq AnimatedChatPhoto
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AnimatedChatPhoto -> AnimatedChatPhoto -> Bool
== :: AnimatedChatPhoto -> AnimatedChatPhoto -> Bool
$c/= :: AnimatedChatPhoto -> AnimatedChatPhoto -> Bool
/= :: AnimatedChatPhoto -> AnimatedChatPhoto -> Bool
Eq, Int -> AnimatedChatPhoto -> ShowS
[AnimatedChatPhoto] -> ShowS
AnimatedChatPhoto -> String
(Int -> AnimatedChatPhoto -> ShowS)
-> (AnimatedChatPhoto -> String)
-> ([AnimatedChatPhoto] -> ShowS)
-> Show AnimatedChatPhoto
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AnimatedChatPhoto -> ShowS
showsPrec :: Int -> AnimatedChatPhoto -> ShowS
$cshow :: AnimatedChatPhoto -> String
show :: AnimatedChatPhoto -> String
$cshowList :: [AnimatedChatPhoto] -> ShowS
showList :: [AnimatedChatPhoto] -> ShowS
Show)
instance I.ShortShow AnimatedChatPhoto where
shortShow :: AnimatedChatPhoto -> String
shortShow AnimatedChatPhoto
{ _length :: AnimatedChatPhoto -> Maybe Int
_length = Maybe Int
_length_
, file :: AnimatedChatPhoto -> Maybe File
file = Maybe File
file_
, main_frame_timestamp :: AnimatedChatPhoto -> Maybe Double
main_frame_timestamp = Maybe Double
main_frame_timestamp_
}
= String
"AnimatedChatPhoto"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_length" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
_length_
, String
"file" String -> Maybe File -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe File
file_
, String
"main_frame_timestamp" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
main_frame_timestamp_
]
instance AT.FromJSON AnimatedChatPhoto where
parseJSON :: Value -> Parser AnimatedChatPhoto
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
"animatedChatPhoto" -> Value -> Parser AnimatedChatPhoto
parseAnimatedChatPhoto Value
v
String
_ -> Parser AnimatedChatPhoto
forall a. Monoid a => a
mempty
where
parseAnimatedChatPhoto :: A.Value -> AT.Parser AnimatedChatPhoto
parseAnimatedChatPhoto :: Value -> Parser AnimatedChatPhoto
parseAnimatedChatPhoto = String
-> (Object -> Parser AnimatedChatPhoto)
-> Value
-> Parser AnimatedChatPhoto
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AnimatedChatPhoto" ((Object -> Parser AnimatedChatPhoto)
-> Value -> Parser AnimatedChatPhoto)
-> (Object -> Parser AnimatedChatPhoto)
-> Value
-> Parser AnimatedChatPhoto
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
_length_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"length"
Maybe File
file_ <- Object
o Object -> Key -> Parser (Maybe File)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"file"
Maybe Double
main_frame_timestamp_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"main_frame_timestamp"
AnimatedChatPhoto -> Parser AnimatedChatPhoto
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AnimatedChatPhoto -> Parser AnimatedChatPhoto)
-> AnimatedChatPhoto -> Parser AnimatedChatPhoto
forall a b. (a -> b) -> a -> b
$ AnimatedChatPhoto
{ _length :: Maybe Int
_length = Maybe Int
_length_
, file :: Maybe File
file = Maybe File
file_
, main_frame_timestamp :: Maybe Double
main_frame_timestamp = Maybe Double
main_frame_timestamp_
}
parseJSON Value
_ = Parser AnimatedChatPhoto
forall a. Monoid a => a
mempty