module TD.Query.SetUserPrivacySettingRules
  (SetUserPrivacySettingRules(..)
  , defaultSetUserPrivacySettingRules
  ) 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.UserPrivacySetting as UserPrivacySetting
import qualified TD.Data.UserPrivacySettingRules as UserPrivacySettingRules

-- | Changes user privacy settings. Returns 'TD.Data.Ok.Ok'
data SetUserPrivacySettingRules
  = SetUserPrivacySettingRules
    { SetUserPrivacySettingRules -> Maybe UserPrivacySetting
setting :: Maybe UserPrivacySetting.UserPrivacySetting           -- ^ The privacy setting
    , SetUserPrivacySettingRules -> Maybe UserPrivacySettingRules
rules   :: Maybe UserPrivacySettingRules.UserPrivacySettingRules -- ^ The new privacy rules
    }
  deriving (SetUserPrivacySettingRules -> SetUserPrivacySettingRules -> Bool
(SetUserPrivacySettingRules -> SetUserPrivacySettingRules -> Bool)
-> (SetUserPrivacySettingRules
    -> SetUserPrivacySettingRules -> Bool)
-> Eq SetUserPrivacySettingRules
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetUserPrivacySettingRules -> SetUserPrivacySettingRules -> Bool
== :: SetUserPrivacySettingRules -> SetUserPrivacySettingRules -> Bool
$c/= :: SetUserPrivacySettingRules -> SetUserPrivacySettingRules -> Bool
/= :: SetUserPrivacySettingRules -> SetUserPrivacySettingRules -> Bool
Eq, Int -> SetUserPrivacySettingRules -> ShowS
[SetUserPrivacySettingRules] -> ShowS
SetUserPrivacySettingRules -> String
(Int -> SetUserPrivacySettingRules -> ShowS)
-> (SetUserPrivacySettingRules -> String)
-> ([SetUserPrivacySettingRules] -> ShowS)
-> Show SetUserPrivacySettingRules
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetUserPrivacySettingRules -> ShowS
showsPrec :: Int -> SetUserPrivacySettingRules -> ShowS
$cshow :: SetUserPrivacySettingRules -> String
show :: SetUserPrivacySettingRules -> String
$cshowList :: [SetUserPrivacySettingRules] -> ShowS
showList :: [SetUserPrivacySettingRules] -> ShowS
Show)

instance I.ShortShow SetUserPrivacySettingRules where
  shortShow :: SetUserPrivacySettingRules -> String
shortShow
    SetUserPrivacySettingRules
      { setting :: SetUserPrivacySettingRules -> Maybe UserPrivacySetting
setting = Maybe UserPrivacySetting
setting_
      , rules :: SetUserPrivacySettingRules -> Maybe UserPrivacySettingRules
rules   = Maybe UserPrivacySettingRules
rules_
      }
        = String
"SetUserPrivacySettingRules"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"setting" String -> Maybe UserPrivacySetting -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe UserPrivacySetting
setting_
          , String
"rules"   String -> Maybe UserPrivacySettingRules -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe UserPrivacySettingRules
rules_
          ]

instance AT.ToJSON SetUserPrivacySettingRules where
  toJSON :: SetUserPrivacySettingRules -> Value
toJSON
    SetUserPrivacySettingRules
      { setting :: SetUserPrivacySettingRules -> Maybe UserPrivacySetting
setting = Maybe UserPrivacySetting
setting_
      , rules :: SetUserPrivacySettingRules -> Maybe UserPrivacySettingRules
rules   = Maybe UserPrivacySettingRules
rules_
      }
        = [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
"setUserPrivacySettingRules"
          , Key
"setting" Key -> Maybe UserPrivacySetting -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe UserPrivacySetting
setting_
          , Key
"rules"   Key -> Maybe UserPrivacySettingRules -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe UserPrivacySettingRules
rules_
          ]

defaultSetUserPrivacySettingRules :: SetUserPrivacySettingRules
defaultSetUserPrivacySettingRules :: SetUserPrivacySettingRules
defaultSetUserPrivacySettingRules =
  SetUserPrivacySettingRules
    { setting :: Maybe UserPrivacySetting
setting = Maybe UserPrivacySetting
forall a. Maybe a
Nothing
    , rules :: Maybe UserPrivacySettingRules
rules   = Maybe UserPrivacySettingRules
forall a. Maybe a
Nothing
    }