module TD.Query.SetNewChatPrivacySettings
  (SetNewChatPrivacySettings(..)
  ) 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.NewChatPrivacySettings as NewChatPrivacySettings

-- | Changes privacy settings for new chat creation; can be used only if getOption("can_set_new_chat_privacy_settings"). Returns 'TD.Data.Ok.Ok'
data SetNewChatPrivacySettings
  = SetNewChatPrivacySettings
    { SetNewChatPrivacySettings -> Maybe NewChatPrivacySettings
settings :: Maybe NewChatPrivacySettings.NewChatPrivacySettings -- ^ New settings
    }
  deriving (SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool
(SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool)
-> (SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool)
-> Eq SetNewChatPrivacySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool
== :: SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool
$c/= :: SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool
/= :: SetNewChatPrivacySettings -> SetNewChatPrivacySettings -> Bool
Eq, Int -> SetNewChatPrivacySettings -> ShowS
[SetNewChatPrivacySettings] -> ShowS
SetNewChatPrivacySettings -> String
(Int -> SetNewChatPrivacySettings -> ShowS)
-> (SetNewChatPrivacySettings -> String)
-> ([SetNewChatPrivacySettings] -> ShowS)
-> Show SetNewChatPrivacySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetNewChatPrivacySettings -> ShowS
showsPrec :: Int -> SetNewChatPrivacySettings -> ShowS
$cshow :: SetNewChatPrivacySettings -> String
show :: SetNewChatPrivacySettings -> String
$cshowList :: [SetNewChatPrivacySettings] -> ShowS
showList :: [SetNewChatPrivacySettings] -> ShowS
Show)

instance I.ShortShow SetNewChatPrivacySettings where
  shortShow :: SetNewChatPrivacySettings -> String
shortShow
    SetNewChatPrivacySettings
      { settings :: SetNewChatPrivacySettings -> Maybe NewChatPrivacySettings
settings = Maybe NewChatPrivacySettings
settings_
      }
        = String
"SetNewChatPrivacySettings"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"settings" String -> Maybe NewChatPrivacySettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe NewChatPrivacySettings
settings_
          ]

instance AT.ToJSON SetNewChatPrivacySettings where
  toJSON :: SetNewChatPrivacySettings -> Value
toJSON
    SetNewChatPrivacySettings
      { settings :: SetNewChatPrivacySettings -> Maybe NewChatPrivacySettings
settings = Maybe NewChatPrivacySettings
settings_
      }
        = [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
"setNewChatPrivacySettings"
          , Key
"settings" Key -> Maybe NewChatPrivacySettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe NewChatPrivacySettings
settings_
          ]