module TD.Query.JoinVideoChat
  (JoinVideoChat(..)
  , defaultJoinVideoChat
  ) 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.MessageSender as MessageSender
import qualified TD.Data.GroupCallJoinParameters as GroupCallJoinParameters
import qualified Data.Text as T

-- | Joins an active video chat. Returns join response payload for tgcalls. Returns 'TD.Data.Text.Text'
data JoinVideoChat
  = JoinVideoChat
    { JoinVideoChat -> Maybe Int
group_call_id   :: Maybe Int                                             -- ^ Group call identifier
    , JoinVideoChat -> Maybe MessageSender
participant_id  :: Maybe MessageSender.MessageSender                     -- ^ Identifier of a group call participant, which will be used to join the call; pass null to join as self; video chats only
    , JoinVideoChat -> Maybe GroupCallJoinParameters
join_parameters :: Maybe GroupCallJoinParameters.GroupCallJoinParameters -- ^ Parameters to join the call
    , JoinVideoChat -> Maybe Text
invite_hash     :: Maybe T.Text                                          -- ^ Invite hash as received from internalLinkTypeVideoChat
    }
  deriving (JoinVideoChat -> JoinVideoChat -> Bool
(JoinVideoChat -> JoinVideoChat -> Bool)
-> (JoinVideoChat -> JoinVideoChat -> Bool) -> Eq JoinVideoChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: JoinVideoChat -> JoinVideoChat -> Bool
== :: JoinVideoChat -> JoinVideoChat -> Bool
$c/= :: JoinVideoChat -> JoinVideoChat -> Bool
/= :: JoinVideoChat -> JoinVideoChat -> Bool
Eq, Int -> JoinVideoChat -> ShowS
[JoinVideoChat] -> ShowS
JoinVideoChat -> String
(Int -> JoinVideoChat -> ShowS)
-> (JoinVideoChat -> String)
-> ([JoinVideoChat] -> ShowS)
-> Show JoinVideoChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JoinVideoChat -> ShowS
showsPrec :: Int -> JoinVideoChat -> ShowS
$cshow :: JoinVideoChat -> String
show :: JoinVideoChat -> String
$cshowList :: [JoinVideoChat] -> ShowS
showList :: [JoinVideoChat] -> ShowS
Show)

instance I.ShortShow JoinVideoChat where
  shortShow :: JoinVideoChat -> String
shortShow
    JoinVideoChat
      { group_call_id :: JoinVideoChat -> Maybe Int
group_call_id   = Maybe Int
group_call_id_
      , participant_id :: JoinVideoChat -> Maybe MessageSender
participant_id  = Maybe MessageSender
participant_id_
      , join_parameters :: JoinVideoChat -> Maybe GroupCallJoinParameters
join_parameters = Maybe GroupCallJoinParameters
join_parameters_
      , invite_hash :: JoinVideoChat -> Maybe Text
invite_hash     = Maybe Text
invite_hash_
      }
        = String
"JoinVideoChat"
          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
"participant_id"  String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
participant_id_
          , String
"join_parameters" String -> Maybe GroupCallJoinParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GroupCallJoinParameters
join_parameters_
          , String
"invite_hash"     String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
invite_hash_
          ]

instance AT.ToJSON JoinVideoChat where
  toJSON :: JoinVideoChat -> Value
toJSON
    JoinVideoChat
      { group_call_id :: JoinVideoChat -> Maybe Int
group_call_id   = Maybe Int
group_call_id_
      , participant_id :: JoinVideoChat -> Maybe MessageSender
participant_id  = Maybe MessageSender
participant_id_
      , join_parameters :: JoinVideoChat -> Maybe GroupCallJoinParameters
join_parameters = Maybe GroupCallJoinParameters
join_parameters_
      , invite_hash :: JoinVideoChat -> Maybe Text
invite_hash     = Maybe Text
invite_hash_
      }
        = [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
"joinVideoChat"
          , 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
"participant_id"  Key -> Maybe MessageSender -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSender
participant_id_
          , Key
"join_parameters" Key -> Maybe GroupCallJoinParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe GroupCallJoinParameters
join_parameters_
          , Key
"invite_hash"     Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
invite_hash_
          ]

defaultJoinVideoChat :: JoinVideoChat
defaultJoinVideoChat :: JoinVideoChat
defaultJoinVideoChat =
  JoinVideoChat
    { group_call_id :: Maybe Int
group_call_id   = Maybe Int
forall a. Maybe a
Nothing
    , participant_id :: Maybe MessageSender
participant_id  = Maybe MessageSender
forall a. Maybe a
Nothing
    , join_parameters :: Maybe GroupCallJoinParameters
join_parameters = Maybe GroupCallJoinParameters
forall a. Maybe a
Nothing
    , invite_hash :: Maybe Text
invite_hash     = Maybe Text
forall a. Maybe a
Nothing
    }