module TD.Data.GroupCallStreams
  (GroupCallStreams(..)) 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.GroupCallStream as GroupCallStream

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

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

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