module TD.Data.GroupCallVideoQuality
  (GroupCallVideoQuality(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Describes the quality of a group call video
data GroupCallVideoQuality
  = GroupCallVideoQualityThumbnail -- ^ The worst available video quality
  | GroupCallVideoQualityMedium -- ^ The medium video quality
  | GroupCallVideoQualityFull -- ^ The best available video quality
  deriving (GroupCallVideoQuality -> GroupCallVideoQuality -> Bool
(GroupCallVideoQuality -> GroupCallVideoQuality -> Bool)
-> (GroupCallVideoQuality -> GroupCallVideoQuality -> Bool)
-> Eq GroupCallVideoQuality
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupCallVideoQuality -> GroupCallVideoQuality -> Bool
== :: GroupCallVideoQuality -> GroupCallVideoQuality -> Bool
$c/= :: GroupCallVideoQuality -> GroupCallVideoQuality -> Bool
/= :: GroupCallVideoQuality -> GroupCallVideoQuality -> Bool
Eq, Int -> GroupCallVideoQuality -> ShowS
[GroupCallVideoQuality] -> ShowS
GroupCallVideoQuality -> String
(Int -> GroupCallVideoQuality -> ShowS)
-> (GroupCallVideoQuality -> String)
-> ([GroupCallVideoQuality] -> ShowS)
-> Show GroupCallVideoQuality
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupCallVideoQuality -> ShowS
showsPrec :: Int -> GroupCallVideoQuality -> ShowS
$cshow :: GroupCallVideoQuality -> String
show :: GroupCallVideoQuality -> String
$cshowList :: [GroupCallVideoQuality] -> ShowS
showList :: [GroupCallVideoQuality] -> ShowS
Show)

instance I.ShortShow GroupCallVideoQuality where
  shortShow :: GroupCallVideoQuality -> String
shortShow GroupCallVideoQuality
GroupCallVideoQualityThumbnail
      = String
"GroupCallVideoQualityThumbnail"
  shortShow GroupCallVideoQuality
GroupCallVideoQualityMedium
      = String
"GroupCallVideoQualityMedium"
  shortShow GroupCallVideoQuality
GroupCallVideoQualityFull
      = String
"GroupCallVideoQualityFull"

instance AT.FromJSON GroupCallVideoQuality where
  parseJSON :: Value -> Parser GroupCallVideoQuality
parseJSON (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
"groupCallVideoQualityThumbnail" -> GroupCallVideoQuality -> Parser GroupCallVideoQuality
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GroupCallVideoQuality
GroupCallVideoQualityThumbnail
      String
"groupCallVideoQualityMedium"    -> GroupCallVideoQuality -> Parser GroupCallVideoQuality
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GroupCallVideoQuality
GroupCallVideoQualityMedium
      String
"groupCallVideoQualityFull"      -> GroupCallVideoQuality -> Parser GroupCallVideoQuality
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GroupCallVideoQuality
GroupCallVideoQualityFull
      String
_                                -> Parser GroupCallVideoQuality
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser GroupCallVideoQuality
forall a. Monoid a => a
mempty

instance AT.ToJSON GroupCallVideoQuality where
  toJSON :: GroupCallVideoQuality -> Value
toJSON GroupCallVideoQuality
GroupCallVideoQualityThumbnail
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"groupCallVideoQualityThumbnail"
        ]
  toJSON GroupCallVideoQuality
GroupCallVideoQualityMedium
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"groupCallVideoQualityMedium"
        ]
  toJSON GroupCallVideoQuality
GroupCallVideoQualityFull
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"groupCallVideoQualityFull"
        ]