module TD.Data.VideoChatStreams
  (VideoChatStreams(..)) 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.VideoChatStream as VideoChatStream

data VideoChatStreams
  = VideoChatStreams -- ^ Represents a list of video chat streams
    { VideoChatStreams -> Maybe [VideoChatStream]
streams :: Maybe [VideoChatStream.VideoChatStream] -- ^ A list of video chat streams
    }
  deriving (VideoChatStreams -> VideoChatStreams -> Bool
(VideoChatStreams -> VideoChatStreams -> Bool)
-> (VideoChatStreams -> VideoChatStreams -> Bool)
-> Eq VideoChatStreams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VideoChatStreams -> VideoChatStreams -> Bool
== :: VideoChatStreams -> VideoChatStreams -> Bool
$c/= :: VideoChatStreams -> VideoChatStreams -> Bool
/= :: VideoChatStreams -> VideoChatStreams -> Bool
Eq, Int -> VideoChatStreams -> ShowS
[VideoChatStreams] -> ShowS
VideoChatStreams -> String
(Int -> VideoChatStreams -> ShowS)
-> (VideoChatStreams -> String)
-> ([VideoChatStreams] -> ShowS)
-> Show VideoChatStreams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VideoChatStreams -> ShowS
showsPrec :: Int -> VideoChatStreams -> ShowS
$cshow :: VideoChatStreams -> String
show :: VideoChatStreams -> String
$cshowList :: [VideoChatStreams] -> ShowS
showList :: [VideoChatStreams] -> ShowS
Show)

instance I.ShortShow VideoChatStreams where
  shortShow :: VideoChatStreams -> String
shortShow VideoChatStreams
    { streams :: VideoChatStreams -> Maybe [VideoChatStream]
streams = Maybe [VideoChatStream]
streams_
    }
      = String
"VideoChatStreams"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"streams" String -> Maybe [VideoChatStream] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [VideoChatStream]
streams_
        ]

instance AT.FromJSON VideoChatStreams where
  parseJSON :: Value -> Parser VideoChatStreams
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
"videoChatStreams" -> Value -> Parser VideoChatStreams
parseVideoChatStreams Value
v
      String
_                  -> Parser VideoChatStreams
forall a. Monoid a => a
mempty
    
    where
      parseVideoChatStreams :: A.Value -> AT.Parser VideoChatStreams
      parseVideoChatStreams :: Value -> Parser VideoChatStreams
parseVideoChatStreams = String
-> (Object -> Parser VideoChatStreams)
-> Value
-> Parser VideoChatStreams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"VideoChatStreams" ((Object -> Parser VideoChatStreams)
 -> Value -> Parser VideoChatStreams)
-> (Object -> Parser VideoChatStreams)
-> Value
-> Parser VideoChatStreams
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe [VideoChatStream]
streams_ <- Object
o Object -> Key -> Parser (Maybe [VideoChatStream])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"streams"
        VideoChatStreams -> Parser VideoChatStreams
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VideoChatStreams -> Parser VideoChatStreams)
-> VideoChatStreams -> Parser VideoChatStreams
forall a b. (a -> b) -> a -> b
$ VideoChatStreams
          { streams :: Maybe [VideoChatStream]
streams = Maybe [VideoChatStream]
streams_
          }
  parseJSON Value
_ = Parser VideoChatStreams
forall a. Monoid a => a
mempty