module TD.Query.CreateVideoChat
  (CreateVideoChat(..)
  , defaultCreateVideoChat
  ) where

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

-- | Creates a video chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_video_chats administrator right. Returns 'TD.Data.GroupCallId.GroupCallId'
data CreateVideoChat
  = CreateVideoChat
    { CreateVideoChat -> Maybe Int
chat_id        :: Maybe Int    -- ^ Identifier of a chat in which the video chat will be created
    , CreateVideoChat -> Maybe Text
title          :: Maybe T.Text -- ^ Group call title; if empty, chat title will be used
    , CreateVideoChat -> Maybe Int
start_date     :: Maybe Int    -- ^ Point in time (Unix timestamp) when the group call is expected to be started by an administrator; 0 to start the video chat immediately. The date must be at least 10 seconds and at most 8 days in the future
    , CreateVideoChat -> Maybe Bool
is_rtmp_stream :: Maybe Bool   -- ^ Pass true to create an RTMP stream instead of an ordinary video chat; requires owner privileges
    }
  deriving (CreateVideoChat -> CreateVideoChat -> Bool
(CreateVideoChat -> CreateVideoChat -> Bool)
-> (CreateVideoChat -> CreateVideoChat -> Bool)
-> Eq CreateVideoChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateVideoChat -> CreateVideoChat -> Bool
== :: CreateVideoChat -> CreateVideoChat -> Bool
$c/= :: CreateVideoChat -> CreateVideoChat -> Bool
/= :: CreateVideoChat -> CreateVideoChat -> Bool
Eq, Int -> CreateVideoChat -> ShowS
[CreateVideoChat] -> ShowS
CreateVideoChat -> String
(Int -> CreateVideoChat -> ShowS)
-> (CreateVideoChat -> String)
-> ([CreateVideoChat] -> ShowS)
-> Show CreateVideoChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateVideoChat -> ShowS
showsPrec :: Int -> CreateVideoChat -> ShowS
$cshow :: CreateVideoChat -> String
show :: CreateVideoChat -> String
$cshowList :: [CreateVideoChat] -> ShowS
showList :: [CreateVideoChat] -> ShowS
Show)

instance I.ShortShow CreateVideoChat where
  shortShow :: CreateVideoChat -> String
shortShow
    CreateVideoChat
      { chat_id :: CreateVideoChat -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , title :: CreateVideoChat -> Maybe Text
title          = Maybe Text
title_
      , start_date :: CreateVideoChat -> Maybe Int
start_date     = Maybe Int
start_date_
      , is_rtmp_stream :: CreateVideoChat -> Maybe Bool
is_rtmp_stream = Maybe Bool
is_rtmp_stream_
      }
        = String
"CreateVideoChat"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"title"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
          , String
"start_date"     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
start_date_
          , String
"is_rtmp_stream" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_rtmp_stream_
          ]

instance AT.ToJSON CreateVideoChat where
  toJSON :: CreateVideoChat -> Value
toJSON
    CreateVideoChat
      { chat_id :: CreateVideoChat -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , title :: CreateVideoChat -> Maybe Text
title          = Maybe Text
title_
      , start_date :: CreateVideoChat -> Maybe Int
start_date     = Maybe Int
start_date_
      , is_rtmp_stream :: CreateVideoChat -> Maybe Bool
is_rtmp_stream = Maybe Bool
is_rtmp_stream_
      }
        = [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
"createVideoChat"
          , Key
"chat_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
chat_id_
          , Key
"title"          Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
title_
          , Key
"start_date"     Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
start_date_
          , Key
"is_rtmp_stream" 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_rtmp_stream_
          ]

defaultCreateVideoChat :: CreateVideoChat
defaultCreateVideoChat :: CreateVideoChat
defaultCreateVideoChat =
  CreateVideoChat
    { chat_id :: Maybe Int
chat_id        = Maybe Int
forall a. Maybe a
Nothing
    , title :: Maybe Text
title          = Maybe Text
forall a. Maybe a
Nothing
    , start_date :: Maybe Int
start_date     = Maybe Int
forall a. Maybe a
Nothing
    , is_rtmp_stream :: Maybe Bool
is_rtmp_stream = Maybe Bool
forall a. Maybe a
Nothing
    }