module TD.Query.ToggleSessionCanAcceptSecretChats
  (ToggleSessionCanAcceptSecretChats(..)
  , defaultToggleSessionCanAcceptSecretChats
  ) where

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

-- | Toggles whether a session can accept incoming secret chats. Returns 'TD.Data.Ok.Ok'
data ToggleSessionCanAcceptSecretChats
  = ToggleSessionCanAcceptSecretChats
    { ToggleSessionCanAcceptSecretChats -> Maybe Int
session_id              :: Maybe Int  -- ^ Session identifier
    , ToggleSessionCanAcceptSecretChats -> Maybe Bool
can_accept_secret_chats :: Maybe Bool -- ^ Pass true to allow accepting secret chats by the session; pass false otherwise
    }
  deriving (ToggleSessionCanAcceptSecretChats
-> ToggleSessionCanAcceptSecretChats -> Bool
(ToggleSessionCanAcceptSecretChats
 -> ToggleSessionCanAcceptSecretChats -> Bool)
-> (ToggleSessionCanAcceptSecretChats
    -> ToggleSessionCanAcceptSecretChats -> Bool)
-> Eq ToggleSessionCanAcceptSecretChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleSessionCanAcceptSecretChats
-> ToggleSessionCanAcceptSecretChats -> Bool
== :: ToggleSessionCanAcceptSecretChats
-> ToggleSessionCanAcceptSecretChats -> Bool
$c/= :: ToggleSessionCanAcceptSecretChats
-> ToggleSessionCanAcceptSecretChats -> Bool
/= :: ToggleSessionCanAcceptSecretChats
-> ToggleSessionCanAcceptSecretChats -> Bool
Eq, Int -> ToggleSessionCanAcceptSecretChats -> ShowS
[ToggleSessionCanAcceptSecretChats] -> ShowS
ToggleSessionCanAcceptSecretChats -> String
(Int -> ToggleSessionCanAcceptSecretChats -> ShowS)
-> (ToggleSessionCanAcceptSecretChats -> String)
-> ([ToggleSessionCanAcceptSecretChats] -> ShowS)
-> Show ToggleSessionCanAcceptSecretChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleSessionCanAcceptSecretChats -> ShowS
showsPrec :: Int -> ToggleSessionCanAcceptSecretChats -> ShowS
$cshow :: ToggleSessionCanAcceptSecretChats -> String
show :: ToggleSessionCanAcceptSecretChats -> String
$cshowList :: [ToggleSessionCanAcceptSecretChats] -> ShowS
showList :: [ToggleSessionCanAcceptSecretChats] -> ShowS
Show)

instance I.ShortShow ToggleSessionCanAcceptSecretChats where
  shortShow :: ToggleSessionCanAcceptSecretChats -> String
shortShow
    ToggleSessionCanAcceptSecretChats
      { session_id :: ToggleSessionCanAcceptSecretChats -> Maybe Int
session_id              = Maybe Int
session_id_
      , can_accept_secret_chats :: ToggleSessionCanAcceptSecretChats -> Maybe Bool
can_accept_secret_chats = Maybe Bool
can_accept_secret_chats_
      }
        = String
"ToggleSessionCanAcceptSecretChats"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"session_id"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
session_id_
          , String
"can_accept_secret_chats" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_accept_secret_chats_
          ]

instance AT.ToJSON ToggleSessionCanAcceptSecretChats where
  toJSON :: ToggleSessionCanAcceptSecretChats -> Value
toJSON
    ToggleSessionCanAcceptSecretChats
      { session_id :: ToggleSessionCanAcceptSecretChats -> Maybe Int
session_id              = Maybe Int
session_id_
      , can_accept_secret_chats :: ToggleSessionCanAcceptSecretChats -> Maybe Bool
can_accept_secret_chats = Maybe Bool
can_accept_secret_chats_
      }
        = [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
"toggleSessionCanAcceptSecretChats"
          , Key
"session_id"              Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
session_id_
          , Key
"can_accept_secret_chats" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_accept_secret_chats_
          ]

defaultToggleSessionCanAcceptSecretChats :: ToggleSessionCanAcceptSecretChats
defaultToggleSessionCanAcceptSecretChats :: ToggleSessionCanAcceptSecretChats
defaultToggleSessionCanAcceptSecretChats =
  ToggleSessionCanAcceptSecretChats
    { session_id :: Maybe Int
session_id              = Maybe Int
forall a. Maybe a
Nothing
    , can_accept_secret_chats :: Maybe Bool
can_accept_secret_chats = Maybe Bool
forall a. Maybe a
Nothing
    }