module TD.Query.JoinLiveStory
  (JoinLiveStory(..)
  , defaultJoinLiveStory
  ) 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.GroupCallJoinParameters as GroupCallJoinParameters

-- | Joins a group call of an active live story. Returns join response payload for tgcalls. Returns 'TD.Data.Text.Text'
data JoinLiveStory
  = JoinLiveStory
    { JoinLiveStory -> Maybe Int
group_call_id   :: Maybe Int                                             -- ^ Group call identifier
    , JoinLiveStory -> Maybe GroupCallJoinParameters
join_parameters :: Maybe GroupCallJoinParameters.GroupCallJoinParameters -- ^ Parameters to join the call
    }
  deriving (JoinLiveStory -> JoinLiveStory -> Bool
(JoinLiveStory -> JoinLiveStory -> Bool)
-> (JoinLiveStory -> JoinLiveStory -> Bool) -> Eq JoinLiveStory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: JoinLiveStory -> JoinLiveStory -> Bool
== :: JoinLiveStory -> JoinLiveStory -> Bool
$c/= :: JoinLiveStory -> JoinLiveStory -> Bool
/= :: JoinLiveStory -> JoinLiveStory -> Bool
Eq, Int -> JoinLiveStory -> ShowS
[JoinLiveStory] -> ShowS
JoinLiveStory -> String
(Int -> JoinLiveStory -> ShowS)
-> (JoinLiveStory -> String)
-> ([JoinLiveStory] -> ShowS)
-> Show JoinLiveStory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JoinLiveStory -> ShowS
showsPrec :: Int -> JoinLiveStory -> ShowS
$cshow :: JoinLiveStory -> String
show :: JoinLiveStory -> String
$cshowList :: [JoinLiveStory] -> ShowS
showList :: [JoinLiveStory] -> ShowS
Show)

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

instance AT.ToJSON JoinLiveStory where
  toJSON :: JoinLiveStory -> Value
toJSON
    JoinLiveStory
      { group_call_id :: JoinLiveStory -> Maybe Int
group_call_id   = Maybe Int
group_call_id_
      , join_parameters :: JoinLiveStory -> Maybe GroupCallJoinParameters
join_parameters = Maybe GroupCallJoinParameters
join_parameters_
      }
        = [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
"joinLiveStory"
          , 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
"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_
          ]

defaultJoinLiveStory :: JoinLiveStory
defaultJoinLiveStory :: JoinLiveStory
defaultJoinLiveStory =
  JoinLiveStory
    { group_call_id :: Maybe Int
group_call_id   = Maybe Int
forall a. Maybe a
Nothing
    , join_parameters :: Maybe GroupCallJoinParameters
join_parameters = Maybe GroupCallJoinParameters
forall a. Maybe a
Nothing
    }