module TD.Query.ToggleChatHasProtectedContent
  (ToggleChatHasProtectedContent(..)
  , defaultToggleChatHasProtectedContent
  ) where

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

-- | Changes the ability of users to save, forward, or copy chat content. Supported only for basic groups, supergroups and channels. Requires owner privileges. Returns 'TD.Data.Ok.Ok'
data ToggleChatHasProtectedContent
  = ToggleChatHasProtectedContent
    { ToggleChatHasProtectedContent -> Maybe Int
chat_id               :: Maybe Int  -- ^ Chat identifier
    , ToggleChatHasProtectedContent -> Maybe Bool
has_protected_content :: Maybe Bool -- ^ New value of has_protected_content
    }
  deriving (ToggleChatHasProtectedContent
-> ToggleChatHasProtectedContent -> Bool
(ToggleChatHasProtectedContent
 -> ToggleChatHasProtectedContent -> Bool)
-> (ToggleChatHasProtectedContent
    -> ToggleChatHasProtectedContent -> Bool)
-> Eq ToggleChatHasProtectedContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleChatHasProtectedContent
-> ToggleChatHasProtectedContent -> Bool
== :: ToggleChatHasProtectedContent
-> ToggleChatHasProtectedContent -> Bool
$c/= :: ToggleChatHasProtectedContent
-> ToggleChatHasProtectedContent -> Bool
/= :: ToggleChatHasProtectedContent
-> ToggleChatHasProtectedContent -> Bool
Eq, Int -> ToggleChatHasProtectedContent -> ShowS
[ToggleChatHasProtectedContent] -> ShowS
ToggleChatHasProtectedContent -> String
(Int -> ToggleChatHasProtectedContent -> ShowS)
-> (ToggleChatHasProtectedContent -> String)
-> ([ToggleChatHasProtectedContent] -> ShowS)
-> Show ToggleChatHasProtectedContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleChatHasProtectedContent -> ShowS
showsPrec :: Int -> ToggleChatHasProtectedContent -> ShowS
$cshow :: ToggleChatHasProtectedContent -> String
show :: ToggleChatHasProtectedContent -> String
$cshowList :: [ToggleChatHasProtectedContent] -> ShowS
showList :: [ToggleChatHasProtectedContent] -> ShowS
Show)

instance I.ShortShow ToggleChatHasProtectedContent where
  shortShow :: ToggleChatHasProtectedContent -> String
shortShow
    ToggleChatHasProtectedContent
      { chat_id :: ToggleChatHasProtectedContent -> Maybe Int
chat_id               = Maybe Int
chat_id_
      , has_protected_content :: ToggleChatHasProtectedContent -> Maybe Bool
has_protected_content = Maybe Bool
has_protected_content_
      }
        = String
"ToggleChatHasProtectedContent"
          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
"has_protected_content" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_protected_content_
          ]

instance AT.ToJSON ToggleChatHasProtectedContent where
  toJSON :: ToggleChatHasProtectedContent -> Value
toJSON
    ToggleChatHasProtectedContent
      { chat_id :: ToggleChatHasProtectedContent -> Maybe Int
chat_id               = Maybe Int
chat_id_
      , has_protected_content :: ToggleChatHasProtectedContent -> Maybe Bool
has_protected_content = Maybe Bool
has_protected_content_
      }
        = [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
"toggleChatHasProtectedContent"
          , 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
"has_protected_content" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
has_protected_content_
          ]

defaultToggleChatHasProtectedContent :: ToggleChatHasProtectedContent
defaultToggleChatHasProtectedContent :: ToggleChatHasProtectedContent
defaultToggleChatHasProtectedContent =
  ToggleChatHasProtectedContent
    { chat_id :: Maybe Int
chat_id               = Maybe Int
forall a. Maybe a
Nothing
    , has_protected_content :: Maybe Bool
has_protected_content = Maybe Bool
forall a. Maybe a
Nothing
    }