module TD.Query.SetCommunityNotificationSettings
  (SetCommunityNotificationSettings(..)
  , defaultSetCommunityNotificationSettings
  ) 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.ChatNotificationSettings as ChatNotificationSettings

-- | Changes notification settings of a community. Returns 'TD.Data.Ok.Ok'
data SetCommunityNotificationSettings
  = SetCommunityNotificationSettings
    { SetCommunityNotificationSettings -> Maybe Int
community_id          :: Maybe Int                                               -- ^ Identifier of the community
    , SetCommunityNotificationSettings -> Maybe ChatNotificationSettings
notification_settings :: Maybe ChatNotificationSettings.ChatNotificationSettings -- ^ New notification settings for the community
    }
  deriving (SetCommunityNotificationSettings
-> SetCommunityNotificationSettings -> Bool
(SetCommunityNotificationSettings
 -> SetCommunityNotificationSettings -> Bool)
-> (SetCommunityNotificationSettings
    -> SetCommunityNotificationSettings -> Bool)
-> Eq SetCommunityNotificationSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCommunityNotificationSettings
-> SetCommunityNotificationSettings -> Bool
== :: SetCommunityNotificationSettings
-> SetCommunityNotificationSettings -> Bool
$c/= :: SetCommunityNotificationSettings
-> SetCommunityNotificationSettings -> Bool
/= :: SetCommunityNotificationSettings
-> SetCommunityNotificationSettings -> Bool
Eq, Int -> SetCommunityNotificationSettings -> ShowS
[SetCommunityNotificationSettings] -> ShowS
SetCommunityNotificationSettings -> String
(Int -> SetCommunityNotificationSettings -> ShowS)
-> (SetCommunityNotificationSettings -> String)
-> ([SetCommunityNotificationSettings] -> ShowS)
-> Show SetCommunityNotificationSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCommunityNotificationSettings -> ShowS
showsPrec :: Int -> SetCommunityNotificationSettings -> ShowS
$cshow :: SetCommunityNotificationSettings -> String
show :: SetCommunityNotificationSettings -> String
$cshowList :: [SetCommunityNotificationSettings] -> ShowS
showList :: [SetCommunityNotificationSettings] -> ShowS
Show)

instance I.ShortShow SetCommunityNotificationSettings where
  shortShow :: SetCommunityNotificationSettings -> String
shortShow
    SetCommunityNotificationSettings
      { community_id :: SetCommunityNotificationSettings -> Maybe Int
community_id          = Maybe Int
community_id_
      , notification_settings :: SetCommunityNotificationSettings -> Maybe ChatNotificationSettings
notification_settings = Maybe ChatNotificationSettings
notification_settings_
      }
        = String
"SetCommunityNotificationSettings"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"community_id"          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
community_id_
          , String
"notification_settings" String -> Maybe ChatNotificationSettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatNotificationSettings
notification_settings_
          ]

instance AT.ToJSON SetCommunityNotificationSettings where
  toJSON :: SetCommunityNotificationSettings -> Value
toJSON
    SetCommunityNotificationSettings
      { community_id :: SetCommunityNotificationSettings -> Maybe Int
community_id          = Maybe Int
community_id_
      , notification_settings :: SetCommunityNotificationSettings -> Maybe ChatNotificationSettings
notification_settings = Maybe ChatNotificationSettings
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
"setCommunityNotificationSettings"
          , Key
"community_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
community_id_
          , Key
"notification_settings" Key -> Maybe ChatNotificationSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatNotificationSettings
notification_settings_
          ]

defaultSetCommunityNotificationSettings :: SetCommunityNotificationSettings
defaultSetCommunityNotificationSettings :: SetCommunityNotificationSettings
defaultSetCommunityNotificationSettings =
  SetCommunityNotificationSettings
    { community_id :: Maybe Int
community_id          = Maybe Int
forall a. Maybe a
Nothing
    , notification_settings :: Maybe ChatNotificationSettings
notification_settings = Maybe ChatNotificationSettings
forall a. Maybe a
Nothing
    }