module TD.Query.RemoveNotification
  (RemoveNotification(..)
  , defaultRemoveNotification
  ) where

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

-- | Removes an active notification from notification list. Needs to be called only if the notification is removed by the current user. Returns 'TD.Data.Ok.Ok'
data RemoveNotification
  = RemoveNotification
    { RemoveNotification -> Maybe Int
notification_group_id :: Maybe Int -- ^ Identifier of notification group to which the notification belongs
    , RemoveNotification -> Maybe Int
notification_id       :: Maybe Int -- ^ Identifier of removed notification
    }
  deriving (RemoveNotification -> RemoveNotification -> Bool
(RemoveNotification -> RemoveNotification -> Bool)
-> (RemoveNotification -> RemoveNotification -> Bool)
-> Eq RemoveNotification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveNotification -> RemoveNotification -> Bool
== :: RemoveNotification -> RemoveNotification -> Bool
$c/= :: RemoveNotification -> RemoveNotification -> Bool
/= :: RemoveNotification -> RemoveNotification -> Bool
Eq, Int -> RemoveNotification -> ShowS
[RemoveNotification] -> ShowS
RemoveNotification -> String
(Int -> RemoveNotification -> ShowS)
-> (RemoveNotification -> String)
-> ([RemoveNotification] -> ShowS)
-> Show RemoveNotification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveNotification -> ShowS
showsPrec :: Int -> RemoveNotification -> ShowS
$cshow :: RemoveNotification -> String
show :: RemoveNotification -> String
$cshowList :: [RemoveNotification] -> ShowS
showList :: [RemoveNotification] -> ShowS
Show)

instance I.ShortShow RemoveNotification where
  shortShow :: RemoveNotification -> String
shortShow
    RemoveNotification
      { notification_group_id :: RemoveNotification -> Maybe Int
notification_group_id = Maybe Int
notification_group_id_
      , notification_id :: RemoveNotification -> Maybe Int
notification_id       = Maybe Int
notification_id_
      }
        = String
"RemoveNotification"
          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
"notification_id"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
notification_id_
          ]

instance AT.ToJSON RemoveNotification where
  toJSON :: RemoveNotification -> Value
toJSON
    RemoveNotification
      { notification_group_id :: RemoveNotification -> Maybe Int
notification_group_id = Maybe Int
notification_group_id_
      , notification_id :: RemoveNotification -> Maybe Int
notification_id       = Maybe Int
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
"removeNotification"
          , 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
"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
notification_id_
          ]

defaultRemoveNotification :: RemoveNotification
defaultRemoveNotification :: RemoveNotification
defaultRemoveNotification =
  RemoveNotification
    { notification_group_id :: Maybe Int
notification_group_id = Maybe Int
forall a. Maybe a
Nothing
    , notification_id :: Maybe Int
notification_id       = Maybe Int
forall a. Maybe a
Nothing
    }