module TD.Query.RemoveNotificationGroup
  (RemoveNotificationGroup(..)
  , defaultRemoveNotificationGroup
  ) where

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

-- | Removes a group of active notifications. Needs to be called only if the notification group is removed by the current user. Returns 'TD.Data.Ok.Ok'
data RemoveNotificationGroup
  = RemoveNotificationGroup
    { RemoveNotificationGroup -> Maybe Int
notification_group_id :: Maybe Int -- ^ Notification group identifier
    , RemoveNotificationGroup -> Maybe Int
max_notification_id   :: Maybe Int -- ^ The maximum identifier of removed notifications
    }
  deriving (RemoveNotificationGroup -> RemoveNotificationGroup -> Bool
(RemoveNotificationGroup -> RemoveNotificationGroup -> Bool)
-> (RemoveNotificationGroup -> RemoveNotificationGroup -> Bool)
-> Eq RemoveNotificationGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveNotificationGroup -> RemoveNotificationGroup -> Bool
== :: RemoveNotificationGroup -> RemoveNotificationGroup -> Bool
$c/= :: RemoveNotificationGroup -> RemoveNotificationGroup -> Bool
/= :: RemoveNotificationGroup -> RemoveNotificationGroup -> Bool
Eq, Int -> RemoveNotificationGroup -> ShowS
[RemoveNotificationGroup] -> ShowS
RemoveNotificationGroup -> String
(Int -> RemoveNotificationGroup -> ShowS)
-> (RemoveNotificationGroup -> String)
-> ([RemoveNotificationGroup] -> ShowS)
-> Show RemoveNotificationGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveNotificationGroup -> ShowS
showsPrec :: Int -> RemoveNotificationGroup -> ShowS
$cshow :: RemoveNotificationGroup -> String
show :: RemoveNotificationGroup -> String
$cshowList :: [RemoveNotificationGroup] -> ShowS
showList :: [RemoveNotificationGroup] -> ShowS
Show)

instance I.ShortShow RemoveNotificationGroup where
  shortShow :: RemoveNotificationGroup -> String
shortShow
    RemoveNotificationGroup
      { notification_group_id :: RemoveNotificationGroup -> Maybe Int
notification_group_id = Maybe Int
notification_group_id_
      , max_notification_id :: RemoveNotificationGroup -> Maybe Int
max_notification_id   = Maybe Int
max_notification_id_
      }
        = String
"RemoveNotificationGroup"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"notification_group_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
notification_group_id_
          , String
"max_notification_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_notification_id_
          ]

instance AT.ToJSON RemoveNotificationGroup where
  toJSON :: RemoveNotificationGroup -> Value
toJSON
    RemoveNotificationGroup
      { notification_group_id :: RemoveNotificationGroup -> Maybe Int
notification_group_id = Maybe Int
notification_group_id_
      , max_notification_id :: RemoveNotificationGroup -> Maybe Int
max_notification_id   = Maybe Int
max_notification_id_
      }
        = [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
"removeNotificationGroup"
          , Key
"notification_group_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
notification_group_id_
          , Key
"max_notification_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
max_notification_id_
          ]

defaultRemoveNotificationGroup :: RemoveNotificationGroup
defaultRemoveNotificationGroup :: RemoveNotificationGroup
defaultRemoveNotificationGroup =
  RemoveNotificationGroup
    { notification_group_id :: Maybe Int
notification_group_id = Maybe Int
forall a. Maybe a
Nothing
    , max_notification_id :: Maybe Int
max_notification_id   = Maybe Int
forall a. Maybe a
Nothing
    }