module TD.Query.SetLogStream
  (SetLogStream(..)
  ) 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.LogStream as LogStream

-- | Sets new log stream for internal logging of TDLib. Can be called synchronously. Returns 'TD.Data.Ok.Ok'
data SetLogStream
  = SetLogStream
    { SetLogStream -> Maybe LogStream
log_stream :: Maybe LogStream.LogStream -- ^ New log stream
    }
  deriving (SetLogStream -> SetLogStream -> Bool
(SetLogStream -> SetLogStream -> Bool)
-> (SetLogStream -> SetLogStream -> Bool) -> Eq SetLogStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetLogStream -> SetLogStream -> Bool
== :: SetLogStream -> SetLogStream -> Bool
$c/= :: SetLogStream -> SetLogStream -> Bool
/= :: SetLogStream -> SetLogStream -> Bool
Eq, Int -> SetLogStream -> ShowS
[SetLogStream] -> ShowS
SetLogStream -> String
(Int -> SetLogStream -> ShowS)
-> (SetLogStream -> String)
-> ([SetLogStream] -> ShowS)
-> Show SetLogStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetLogStream -> ShowS
showsPrec :: Int -> SetLogStream -> ShowS
$cshow :: SetLogStream -> String
show :: SetLogStream -> String
$cshowList :: [SetLogStream] -> ShowS
showList :: [SetLogStream] -> ShowS
Show)

instance I.ShortShow SetLogStream where
  shortShow :: SetLogStream -> String
shortShow
    SetLogStream
      { log_stream :: SetLogStream -> Maybe LogStream
log_stream = Maybe LogStream
log_stream_
      }
        = String
"SetLogStream"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"log_stream" String -> Maybe LogStream -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe LogStream
log_stream_
          ]

instance AT.ToJSON SetLogStream where
  toJSON :: SetLogStream -> Value
toJSON
    SetLogStream
      { log_stream :: SetLogStream -> Maybe LogStream
log_stream = Maybe LogStream
log_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
"setLogStream"
          , Key
"log_stream" Key -> Maybe LogStream -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe LogStream
log_stream_
          ]