module TD.Query.GetVideoChatStreamSegment
  (GetVideoChatStreamSegment(..)
  , defaultGetVideoChatStreamSegment
  ) 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.GroupCallVideoQuality as GroupCallVideoQuality

-- | Returns a file with a segment of a video chat stream in a modified OGG format for audio or MPEG-4 format for video. Returns 'TD.Data.Data.Data'
data GetVideoChatStreamSegment
  = GetVideoChatStreamSegment
    { GetVideoChatStreamSegment -> Maybe Int
group_call_id :: Maybe Int                                         -- ^ Group call identifier
    , GetVideoChatStreamSegment -> Maybe Int
time_offset   :: Maybe Int                                         -- ^ Point in time when the stream segment begins; Unix timestamp in milliseconds
    , GetVideoChatStreamSegment -> Maybe Int
scale         :: Maybe Int                                         -- ^ Segment duration scale; 0-1. Segment's duration is 1000/(2**scale) milliseconds
    , GetVideoChatStreamSegment -> Maybe Int
channel_id    :: Maybe Int                                         -- ^ Identifier of an audio/video channel to get as received from tgcalls
    , GetVideoChatStreamSegment -> Maybe GroupCallVideoQuality
video_quality :: Maybe GroupCallVideoQuality.GroupCallVideoQuality -- ^ Video quality as received from tgcalls; pass null to get the worst available quality
    }
  deriving (GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool
(GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool)
-> (GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool)
-> Eq GetVideoChatStreamSegment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool
== :: GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool
$c/= :: GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool
/= :: GetVideoChatStreamSegment -> GetVideoChatStreamSegment -> Bool
Eq, Int -> GetVideoChatStreamSegment -> ShowS
[GetVideoChatStreamSegment] -> ShowS
GetVideoChatStreamSegment -> String
(Int -> GetVideoChatStreamSegment -> ShowS)
-> (GetVideoChatStreamSegment -> String)
-> ([GetVideoChatStreamSegment] -> ShowS)
-> Show GetVideoChatStreamSegment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetVideoChatStreamSegment -> ShowS
showsPrec :: Int -> GetVideoChatStreamSegment -> ShowS
$cshow :: GetVideoChatStreamSegment -> String
show :: GetVideoChatStreamSegment -> String
$cshowList :: [GetVideoChatStreamSegment] -> ShowS
showList :: [GetVideoChatStreamSegment] -> ShowS
Show)

instance I.ShortShow GetVideoChatStreamSegment where
  shortShow :: GetVideoChatStreamSegment -> String
shortShow
    GetVideoChatStreamSegment
      { group_call_id :: GetVideoChatStreamSegment -> Maybe Int
group_call_id = Maybe Int
group_call_id_
      , time_offset :: GetVideoChatStreamSegment -> Maybe Int
time_offset   = Maybe Int
time_offset_
      , scale :: GetVideoChatStreamSegment -> Maybe Int
scale         = Maybe Int
scale_
      , channel_id :: GetVideoChatStreamSegment -> Maybe Int
channel_id    = Maybe Int
channel_id_
      , video_quality :: GetVideoChatStreamSegment -> Maybe GroupCallVideoQuality
video_quality = Maybe GroupCallVideoQuality
video_quality_
      }
        = String
"GetVideoChatStreamSegment"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"group_call_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
group_call_id_
          , String
"time_offset"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
time_offset_
          , String
"scale"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
scale_
          , String
"channel_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
channel_id_
          , String
"video_quality" String -> Maybe GroupCallVideoQuality -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GroupCallVideoQuality
video_quality_
          ]

instance AT.ToJSON GetVideoChatStreamSegment where
  toJSON :: GetVideoChatStreamSegment -> Value
toJSON
    GetVideoChatStreamSegment
      { group_call_id :: GetVideoChatStreamSegment -> Maybe Int
group_call_id = Maybe Int
group_call_id_
      , time_offset :: GetVideoChatStreamSegment -> Maybe Int
time_offset   = Maybe Int
time_offset_
      , scale :: GetVideoChatStreamSegment -> Maybe Int
scale         = Maybe Int
scale_
      , channel_id :: GetVideoChatStreamSegment -> Maybe Int
channel_id    = Maybe Int
channel_id_
      , video_quality :: GetVideoChatStreamSegment -> Maybe GroupCallVideoQuality
video_quality = Maybe GroupCallVideoQuality
video_quality_
      }
        = [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
"getVideoChatStreamSegment"
          , Key
"group_call_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
group_call_id_
          , Key
"time_offset"   Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
time_offset_
          , Key
"scale"         Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
scale_
          , Key
"channel_id"    Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
channel_id_
          , Key
"video_quality" Key -> Maybe GroupCallVideoQuality -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe GroupCallVideoQuality
video_quality_
          ]

defaultGetVideoChatStreamSegment :: GetVideoChatStreamSegment
defaultGetVideoChatStreamSegment :: GetVideoChatStreamSegment
defaultGetVideoChatStreamSegment =
  GetVideoChatStreamSegment
    { group_call_id :: Maybe Int
group_call_id = Maybe Int
forall a. Maybe a
Nothing
    , time_offset :: Maybe Int
time_offset   = Maybe Int
forall a. Maybe a
Nothing
    , scale :: Maybe Int
scale         = Maybe Int
forall a. Maybe a
Nothing
    , channel_id :: Maybe Int
channel_id    = Maybe Int
forall a. Maybe a
Nothing
    , video_quality :: Maybe GroupCallVideoQuality
video_quality = Maybe GroupCallVideoQuality
forall a. Maybe a
Nothing
    }