module TD.Query.SetScopeNotificationSettings
  (SetScopeNotificationSettings(..)
  , defaultSetScopeNotificationSettings
  ) 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.NotificationSettingsScope as NotificationSettingsScope
import qualified TD.Data.ScopeNotificationSettings as ScopeNotificationSettings

-- | Changes notification settings for chats of a given type. Returns 'TD.Data.Ok.Ok'
data SetScopeNotificationSettings
  = SetScopeNotificationSettings
    { SetScopeNotificationSettings -> Maybe NotificationSettingsScope
scope                 :: Maybe NotificationSettingsScope.NotificationSettingsScope -- ^ Types of chats for which to change the notification settings
    , SetScopeNotificationSettings -> Maybe ScopeNotificationSettings
notification_settings :: Maybe ScopeNotificationSettings.ScopeNotificationSettings -- ^ The new notification settings for the given scope
    }
  deriving (SetScopeNotificationSettings
-> SetScopeNotificationSettings -> Bool
(SetScopeNotificationSettings
 -> SetScopeNotificationSettings -> Bool)
-> (SetScopeNotificationSettings
    -> SetScopeNotificationSettings -> Bool)
-> Eq SetScopeNotificationSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetScopeNotificationSettings
-> SetScopeNotificationSettings -> Bool
== :: SetScopeNotificationSettings
-> SetScopeNotificationSettings -> Bool
$c/= :: SetScopeNotificationSettings
-> SetScopeNotificationSettings -> Bool
/= :: SetScopeNotificationSettings
-> SetScopeNotificationSettings -> Bool
Eq, Int -> SetScopeNotificationSettings -> ShowS
[SetScopeNotificationSettings] -> ShowS
SetScopeNotificationSettings -> String
(Int -> SetScopeNotificationSettings -> ShowS)
-> (SetScopeNotificationSettings -> String)
-> ([SetScopeNotificationSettings] -> ShowS)
-> Show SetScopeNotificationSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetScopeNotificationSettings -> ShowS
showsPrec :: Int -> SetScopeNotificationSettings -> ShowS
$cshow :: SetScopeNotificationSettings -> String
show :: SetScopeNotificationSettings -> String
$cshowList :: [SetScopeNotificationSettings] -> ShowS
showList :: [SetScopeNotificationSettings] -> ShowS
Show)

instance I.ShortShow SetScopeNotificationSettings where
  shortShow :: SetScopeNotificationSettings -> String
shortShow
    SetScopeNotificationSettings
      { scope :: SetScopeNotificationSettings -> Maybe NotificationSettingsScope
scope                 = Maybe NotificationSettingsScope
scope_
      , notification_settings :: SetScopeNotificationSettings -> Maybe ScopeNotificationSettings
notification_settings = Maybe ScopeNotificationSettings
notification_settings_
      }
        = String
"SetScopeNotificationSettings"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"scope"                 String -> Maybe NotificationSettingsScope -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe NotificationSettingsScope
scope_
          , String
"notification_settings" String -> Maybe ScopeNotificationSettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ScopeNotificationSettings
notification_settings_
          ]

instance AT.ToJSON SetScopeNotificationSettings where
  toJSON :: SetScopeNotificationSettings -> Value
toJSON
    SetScopeNotificationSettings
      { scope :: SetScopeNotificationSettings -> Maybe NotificationSettingsScope
scope                 = Maybe NotificationSettingsScope
scope_
      , notification_settings :: SetScopeNotificationSettings -> Maybe ScopeNotificationSettings
notification_settings = Maybe ScopeNotificationSettings
notification_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
"setScopeNotificationSettings"
          , Key
"scope"                 Key -> Maybe NotificationSettingsScope -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe NotificationSettingsScope
scope_
          , Key
"notification_settings" Key -> Maybe ScopeNotificationSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ScopeNotificationSettings
notification_settings_
          ]

defaultSetScopeNotificationSettings :: SetScopeNotificationSettings
defaultSetScopeNotificationSettings :: SetScopeNotificationSettings
defaultSetScopeNotificationSettings =
  SetScopeNotificationSettings
    { scope :: Maybe NotificationSettingsScope
scope                 = Maybe NotificationSettingsScope
forall a. Maybe a
Nothing
    , notification_settings :: Maybe ScopeNotificationSettings
notification_settings = Maybe ScopeNotificationSettings
forall a. Maybe a
Nothing
    }