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

instance I.ShortShow GetGroupCallStreamSegment where
  shortShow :: GetGroupCallStreamSegment -> String
shortShow
    GetGroupCallStreamSegment
      { group_call_id :: GetGroupCallStreamSegment -> Maybe Int
group_call_id = Maybe Int
group_call_id_
      , time_offset :: GetGroupCallStreamSegment -> Maybe Int
time_offset   = Maybe Int
time_offset_
      , scale :: GetGroupCallStreamSegment -> Maybe Int
scale         = Maybe Int
scale_
      , channel_id :: GetGroupCallStreamSegment -> Maybe Int
channel_id    = Maybe Int
channel_id_
      , video_quality :: GetGroupCallStreamSegment -> Maybe GroupCallVideoQuality
video_quality = Maybe GroupCallVideoQuality
video_quality_
      }
        = String
"GetGroupCallStreamSegment"
          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 GetGroupCallStreamSegment where
  toJSON :: GetGroupCallStreamSegment -> Value
toJSON
    GetGroupCallStreamSegment
      { group_call_id :: GetGroupCallStreamSegment -> Maybe Int
group_call_id = Maybe Int
group_call_id_
      , time_offset :: GetGroupCallStreamSegment -> Maybe Int
time_offset   = Maybe Int
time_offset_
      , scale :: GetGroupCallStreamSegment -> Maybe Int
scale         = Maybe Int
scale_
      , channel_id :: GetGroupCallStreamSegment -> Maybe Int
channel_id    = Maybe Int
channel_id_
      , video_quality :: GetGroupCallStreamSegment -> 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
"getGroupCallStreamSegment"
          , 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_
          ]

defaultGetGroupCallStreamSegment :: GetGroupCallStreamSegment
defaultGetGroupCallStreamSegment :: GetGroupCallStreamSegment
defaultGetGroupCallStreamSegment =
  GetGroupCallStreamSegment
    { 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
    }