module TD.Data.NotificationGroupType
  (NotificationGroupType(..)) where

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

-- | Describes the type of notifications in a notification group
data NotificationGroupType
  = NotificationGroupTypeMessages -- ^ A group containing notifications of type notificationTypeNewMessage and notificationTypeNewPushMessage with ordinary unread messages
  | NotificationGroupTypeMentions -- ^ A group containing notifications of type notificationTypeNewMessage and notificationTypeNewPushMessage with unread mentions of the current user, replies to their messages, or a pinned message
  | NotificationGroupTypeSecretChat -- ^ A group containing a notification of type notificationTypeNewSecretChat
  | NotificationGroupTypeCalls -- ^ A group containing notifications of type notificationTypeNewCall
  deriving (NotificationGroupType -> NotificationGroupType -> Bool
(NotificationGroupType -> NotificationGroupType -> Bool)
-> (NotificationGroupType -> NotificationGroupType -> Bool)
-> Eq NotificationGroupType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NotificationGroupType -> NotificationGroupType -> Bool
== :: NotificationGroupType -> NotificationGroupType -> Bool
$c/= :: NotificationGroupType -> NotificationGroupType -> Bool
/= :: NotificationGroupType -> NotificationGroupType -> Bool
Eq, Int -> NotificationGroupType -> ShowS
[NotificationGroupType] -> ShowS
NotificationGroupType -> String
(Int -> NotificationGroupType -> ShowS)
-> (NotificationGroupType -> String)
-> ([NotificationGroupType] -> ShowS)
-> Show NotificationGroupType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NotificationGroupType -> ShowS
showsPrec :: Int -> NotificationGroupType -> ShowS
$cshow :: NotificationGroupType -> String
show :: NotificationGroupType -> String
$cshowList :: [NotificationGroupType] -> ShowS
showList :: [NotificationGroupType] -> ShowS
Show)

instance I.ShortShow NotificationGroupType where
  shortShow :: NotificationGroupType -> String
shortShow NotificationGroupType
NotificationGroupTypeMessages
      = String
"NotificationGroupTypeMessages"
  shortShow NotificationGroupType
NotificationGroupTypeMentions
      = String
"NotificationGroupTypeMentions"
  shortShow NotificationGroupType
NotificationGroupTypeSecretChat
      = String
"NotificationGroupTypeSecretChat"
  shortShow NotificationGroupType
NotificationGroupTypeCalls
      = String
"NotificationGroupTypeCalls"

instance AT.FromJSON NotificationGroupType where
  parseJSON :: Value -> Parser NotificationGroupType
parseJSON (AT.Object Object
obj) = do
    String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String

    case String
t of
      String
"notificationGroupTypeMessages"   -> NotificationGroupType -> Parser NotificationGroupType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NotificationGroupType
NotificationGroupTypeMessages
      String
"notificationGroupTypeMentions"   -> NotificationGroupType -> Parser NotificationGroupType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NotificationGroupType
NotificationGroupTypeMentions
      String
"notificationGroupTypeSecretChat" -> NotificationGroupType -> Parser NotificationGroupType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NotificationGroupType
NotificationGroupTypeSecretChat
      String
"notificationGroupTypeCalls"      -> NotificationGroupType -> Parser NotificationGroupType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NotificationGroupType
NotificationGroupTypeCalls
      String
_                                 -> Parser NotificationGroupType
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser NotificationGroupType
forall a. Monoid a => a
mempty