module TD.Query.SendCallLog
  (SendCallLog(..)
  , defaultSendCallLog
  ) 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.InputFile as InputFile

-- | Sends log file for a call to Telegram servers. Returns 'TD.Data.Ok.Ok'
data SendCallLog
  = SendCallLog
    { SendCallLog -> Maybe Int
call_id  :: Maybe Int                 -- ^ Call identifier
    , SendCallLog -> Maybe InputFile
log_file :: Maybe InputFile.InputFile -- ^ Call log file. Only inputFileLocal and inputFileGenerated are supported
    }
  deriving (SendCallLog -> SendCallLog -> Bool
(SendCallLog -> SendCallLog -> Bool)
-> (SendCallLog -> SendCallLog -> Bool) -> Eq SendCallLog
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendCallLog -> SendCallLog -> Bool
== :: SendCallLog -> SendCallLog -> Bool
$c/= :: SendCallLog -> SendCallLog -> Bool
/= :: SendCallLog -> SendCallLog -> Bool
Eq, Int -> SendCallLog -> ShowS
[SendCallLog] -> ShowS
SendCallLog -> String
(Int -> SendCallLog -> ShowS)
-> (SendCallLog -> String)
-> ([SendCallLog] -> ShowS)
-> Show SendCallLog
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendCallLog -> ShowS
showsPrec :: Int -> SendCallLog -> ShowS
$cshow :: SendCallLog -> String
show :: SendCallLog -> String
$cshowList :: [SendCallLog] -> ShowS
showList :: [SendCallLog] -> ShowS
Show)

instance I.ShortShow SendCallLog where
  shortShow :: SendCallLog -> String
shortShow
    SendCallLog
      { call_id :: SendCallLog -> Maybe Int
call_id  = Maybe Int
call_id_
      , log_file :: SendCallLog -> Maybe InputFile
log_file = Maybe InputFile
log_file_
      }
        = String
"SendCallLog"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"call_id"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
call_id_
          , String
"log_file" String -> Maybe InputFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputFile
log_file_
          ]

instance AT.ToJSON SendCallLog where
  toJSON :: SendCallLog -> Value
toJSON
    SendCallLog
      { call_id :: SendCallLog -> Maybe Int
call_id  = Maybe Int
call_id_
      , log_file :: SendCallLog -> Maybe InputFile
log_file = Maybe InputFile
log_file_
      }
        = [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
"sendCallLog"
          , Key
"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
call_id_
          , Key
"log_file" Key -> Maybe InputFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputFile
log_file_
          ]

defaultSendCallLog :: SendCallLog
defaultSendCallLog :: SendCallLog
defaultSendCallLog =
  SendCallLog
    { call_id :: Maybe Int
call_id  = Maybe Int
forall a. Maybe a
Nothing
    , log_file :: Maybe InputFile
log_file = Maybe InputFile
forall a. Maybe a
Nothing
    }