module TD.Data.GroupCallStream
(GroupCallStream(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data GroupCallStream
= GroupCallStream
{ GroupCallStream -> Maybe Int
channel_id :: Maybe Int
, GroupCallStream -> Maybe Int
scale :: Maybe Int
, GroupCallStream -> Maybe Int
time_offset :: Maybe Int
}
deriving (GroupCallStream -> GroupCallStream -> Bool
(GroupCallStream -> GroupCallStream -> Bool)
-> (GroupCallStream -> GroupCallStream -> Bool)
-> Eq GroupCallStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupCallStream -> GroupCallStream -> Bool
== :: GroupCallStream -> GroupCallStream -> Bool
$c/= :: GroupCallStream -> GroupCallStream -> Bool
/= :: GroupCallStream -> GroupCallStream -> Bool
Eq, Int -> GroupCallStream -> ShowS
[GroupCallStream] -> ShowS
GroupCallStream -> String
(Int -> GroupCallStream -> ShowS)
-> (GroupCallStream -> String)
-> ([GroupCallStream] -> ShowS)
-> Show GroupCallStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupCallStream -> ShowS
showsPrec :: Int -> GroupCallStream -> ShowS
$cshow :: GroupCallStream -> String
show :: GroupCallStream -> String
$cshowList :: [GroupCallStream] -> ShowS
showList :: [GroupCallStream] -> ShowS
Show)
instance I.ShortShow GroupCallStream where
shortShow :: GroupCallStream -> String
shortShow GroupCallStream
{ channel_id :: GroupCallStream -> Maybe Int
channel_id = Maybe Int
channel_id_
, scale :: GroupCallStream -> Maybe Int
scale = Maybe Int
scale_
, time_offset :: GroupCallStream -> Maybe Int
time_offset = Maybe Int
time_offset_
}
= String
"GroupCallStream"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"channel_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
channel_id_
, String
"scale" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
scale_
, String
"time_offset" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
time_offset_
]
instance AT.FromJSON GroupCallStream where
parseJSON :: Value -> Parser GroupCallStream
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
"groupCallStream" -> Value -> Parser GroupCallStream
parseGroupCallStream Value
v
String
_ -> Parser GroupCallStream
forall a. Monoid a => a
mempty
where
parseGroupCallStream :: A.Value -> AT.Parser GroupCallStream
parseGroupCallStream :: Value -> Parser GroupCallStream
parseGroupCallStream = String
-> (Object -> Parser GroupCallStream)
-> Value
-> Parser GroupCallStream
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GroupCallStream" ((Object -> Parser GroupCallStream)
-> Value -> Parser GroupCallStream)
-> (Object -> Parser GroupCallStream)
-> Value
-> Parser GroupCallStream
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
channel_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"channel_id"
Maybe Int
scale_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"scale"
Maybe Int
time_offset_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"time_offset"
GroupCallStream -> Parser GroupCallStream
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GroupCallStream -> Parser GroupCallStream)
-> GroupCallStream -> Parser GroupCallStream
forall a b. (a -> b) -> a -> b
$ GroupCallStream
{ channel_id :: Maybe Int
channel_id = Maybe Int
channel_id_
, scale :: Maybe Int
scale = Maybe Int
scale_
, time_offset :: Maybe Int
time_offset = Maybe Int
time_offset_
}
parseJSON Value
_ = Parser GroupCallStream
forall a. Monoid a => a
mempty