module TD.Query.SetGroupCallParticipantIsSpeaking
  (SetGroupCallParticipantIsSpeaking(..)
  , defaultSetGroupCallParticipantIsSpeaking
  ) where

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

-- | Informs TDLib that speaking state of a participant of an active group has changed. Returns 'TD.Data.Ok.Ok'
data SetGroupCallParticipantIsSpeaking
  = SetGroupCallParticipantIsSpeaking
    { SetGroupCallParticipantIsSpeaking -> Maybe Int
group_call_id :: Maybe Int  -- ^ Group call identifier
    , SetGroupCallParticipantIsSpeaking -> Maybe Int
audio_source  :: Maybe Int  -- ^ Group call participant's synchronization audio source identifier, or 0 for the current user
    , SetGroupCallParticipantIsSpeaking -> Maybe Bool
is_speaking   :: Maybe Bool -- ^ Pass true if the user is speaking
    }
  deriving (SetGroupCallParticipantIsSpeaking
-> SetGroupCallParticipantIsSpeaking -> Bool
(SetGroupCallParticipantIsSpeaking
 -> SetGroupCallParticipantIsSpeaking -> Bool)
-> (SetGroupCallParticipantIsSpeaking
    -> SetGroupCallParticipantIsSpeaking -> Bool)
-> Eq SetGroupCallParticipantIsSpeaking
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetGroupCallParticipantIsSpeaking
-> SetGroupCallParticipantIsSpeaking -> Bool
== :: SetGroupCallParticipantIsSpeaking
-> SetGroupCallParticipantIsSpeaking -> Bool
$c/= :: SetGroupCallParticipantIsSpeaking
-> SetGroupCallParticipantIsSpeaking -> Bool
/= :: SetGroupCallParticipantIsSpeaking
-> SetGroupCallParticipantIsSpeaking -> Bool
Eq, Int -> SetGroupCallParticipantIsSpeaking -> ShowS
[SetGroupCallParticipantIsSpeaking] -> ShowS
SetGroupCallParticipantIsSpeaking -> String
(Int -> SetGroupCallParticipantIsSpeaking -> ShowS)
-> (SetGroupCallParticipantIsSpeaking -> String)
-> ([SetGroupCallParticipantIsSpeaking] -> ShowS)
-> Show SetGroupCallParticipantIsSpeaking
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetGroupCallParticipantIsSpeaking -> ShowS
showsPrec :: Int -> SetGroupCallParticipantIsSpeaking -> ShowS
$cshow :: SetGroupCallParticipantIsSpeaking -> String
show :: SetGroupCallParticipantIsSpeaking -> String
$cshowList :: [SetGroupCallParticipantIsSpeaking] -> ShowS
showList :: [SetGroupCallParticipantIsSpeaking] -> ShowS
Show)

instance I.ShortShow SetGroupCallParticipantIsSpeaking where
  shortShow :: SetGroupCallParticipantIsSpeaking -> String
shortShow
    SetGroupCallParticipantIsSpeaking
      { group_call_id :: SetGroupCallParticipantIsSpeaking -> Maybe Int
group_call_id = Maybe Int
group_call_id_
      , audio_source :: SetGroupCallParticipantIsSpeaking -> Maybe Int
audio_source  = Maybe Int
audio_source_
      , is_speaking :: SetGroupCallParticipantIsSpeaking -> Maybe Bool
is_speaking   = Maybe Bool
is_speaking_
      }
        = String
"SetGroupCallParticipantIsSpeaking"
          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
"audio_source"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
audio_source_
          , String
"is_speaking"   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_speaking_
          ]

instance AT.ToJSON SetGroupCallParticipantIsSpeaking where
  toJSON :: SetGroupCallParticipantIsSpeaking -> Value
toJSON
    SetGroupCallParticipantIsSpeaking
      { group_call_id :: SetGroupCallParticipantIsSpeaking -> Maybe Int
group_call_id = Maybe Int
group_call_id_
      , audio_source :: SetGroupCallParticipantIsSpeaking -> Maybe Int
audio_source  = Maybe Int
audio_source_
      , is_speaking :: SetGroupCallParticipantIsSpeaking -> Maybe Bool
is_speaking   = Maybe Bool
is_speaking_
      }
        = [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
"setGroupCallParticipantIsSpeaking"
          , 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
"audio_source"  Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
audio_source_
          , Key
"is_speaking"   Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_speaking_
          ]

defaultSetGroupCallParticipantIsSpeaking :: SetGroupCallParticipantIsSpeaking
defaultSetGroupCallParticipantIsSpeaking :: SetGroupCallParticipantIsSpeaking
defaultSetGroupCallParticipantIsSpeaking =
  SetGroupCallParticipantIsSpeaking
    { group_call_id :: Maybe Int
group_call_id = Maybe Int
forall a. Maybe a
Nothing
    , audio_source :: Maybe Int
audio_source  = Maybe Int
forall a. Maybe a
Nothing
    , is_speaking :: Maybe Bool
is_speaking   = Maybe Bool
forall a. Maybe a
Nothing
    }