module TD.Data.ScopeNotificationSettings
( ScopeNotificationSettings(..)
, defaultScopeNotificationSettings
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ScopeNotificationSettings
= ScopeNotificationSettings
{ ScopeNotificationSettings -> Maybe Int
mute_for :: Maybe Int
, ScopeNotificationSettings -> Maybe Int
sound_id :: Maybe Int
, ScopeNotificationSettings -> Maybe Bool
show_preview :: Maybe Bool
, ScopeNotificationSettings -> Maybe Bool
use_default_mute_stories :: Maybe Bool
, ScopeNotificationSettings -> Maybe Bool
mute_stories :: Maybe Bool
, ScopeNotificationSettings -> Maybe Int
story_sound_id :: Maybe Int
, ScopeNotificationSettings -> Maybe Bool
show_story_sender :: Maybe Bool
, ScopeNotificationSettings -> Maybe Bool
disable_pinned_message_notifications :: Maybe Bool
, ScopeNotificationSettings -> Maybe Bool
disable_mention_notifications :: Maybe Bool
}
deriving (ScopeNotificationSettings -> ScopeNotificationSettings -> Bool
(ScopeNotificationSettings -> ScopeNotificationSettings -> Bool)
-> (ScopeNotificationSettings -> ScopeNotificationSettings -> Bool)
-> Eq ScopeNotificationSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScopeNotificationSettings -> ScopeNotificationSettings -> Bool
== :: ScopeNotificationSettings -> ScopeNotificationSettings -> Bool
$c/= :: ScopeNotificationSettings -> ScopeNotificationSettings -> Bool
/= :: ScopeNotificationSettings -> ScopeNotificationSettings -> Bool
Eq, Int -> ScopeNotificationSettings -> ShowS
[ScopeNotificationSettings] -> ShowS
ScopeNotificationSettings -> String
(Int -> ScopeNotificationSettings -> ShowS)
-> (ScopeNotificationSettings -> String)
-> ([ScopeNotificationSettings] -> ShowS)
-> Show ScopeNotificationSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScopeNotificationSettings -> ShowS
showsPrec :: Int -> ScopeNotificationSettings -> ShowS
$cshow :: ScopeNotificationSettings -> String
show :: ScopeNotificationSettings -> String
$cshowList :: [ScopeNotificationSettings] -> ShowS
showList :: [ScopeNotificationSettings] -> ShowS
Show)
instance I.ShortShow ScopeNotificationSettings where
shortShow :: ScopeNotificationSettings -> String
shortShow ScopeNotificationSettings
{ mute_for :: ScopeNotificationSettings -> Maybe Int
mute_for = Maybe Int
mute_for_
, sound_id :: ScopeNotificationSettings -> Maybe Int
sound_id = Maybe Int
sound_id_
, show_preview :: ScopeNotificationSettings -> Maybe Bool
show_preview = Maybe Bool
show_preview_
, use_default_mute_stories :: ScopeNotificationSettings -> Maybe Bool
use_default_mute_stories = Maybe Bool
use_default_mute_stories_
, mute_stories :: ScopeNotificationSettings -> Maybe Bool
mute_stories = Maybe Bool
mute_stories_
, story_sound_id :: ScopeNotificationSettings -> Maybe Int
story_sound_id = Maybe Int
story_sound_id_
, show_story_sender :: ScopeNotificationSettings -> Maybe Bool
show_story_sender = Maybe Bool
show_story_sender_
, disable_pinned_message_notifications :: ScopeNotificationSettings -> Maybe Bool
disable_pinned_message_notifications = Maybe Bool
disable_pinned_message_notifications_
, disable_mention_notifications :: ScopeNotificationSettings -> Maybe Bool
disable_mention_notifications = Maybe Bool
disable_mention_notifications_
}
= String
"ScopeNotificationSettings"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"mute_for" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
mute_for_
, String
"sound_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
sound_id_
, String
"show_preview" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
show_preview_
, String
"use_default_mute_stories" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
use_default_mute_stories_
, String
"mute_stories" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
mute_stories_
, String
"story_sound_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_sound_id_
, String
"show_story_sender" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
show_story_sender_
, String
"disable_pinned_message_notifications" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
disable_pinned_message_notifications_
, String
"disable_mention_notifications" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
disable_mention_notifications_
]
instance AT.FromJSON ScopeNotificationSettings where
parseJSON :: Value -> Parser ScopeNotificationSettings
parseJSON v :: Value
v@(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
"scopeNotificationSettings" -> Value -> Parser ScopeNotificationSettings
parseScopeNotificationSettings Value
v
String
_ -> Parser ScopeNotificationSettings
forall a. Monoid a => a
mempty
where
parseScopeNotificationSettings :: A.Value -> AT.Parser ScopeNotificationSettings
parseScopeNotificationSettings :: Value -> Parser ScopeNotificationSettings
parseScopeNotificationSettings = String
-> (Object -> Parser ScopeNotificationSettings)
-> Value
-> Parser ScopeNotificationSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ScopeNotificationSettings" ((Object -> Parser ScopeNotificationSettings)
-> Value -> Parser ScopeNotificationSettings)
-> (Object -> Parser ScopeNotificationSettings)
-> Value
-> Parser ScopeNotificationSettings
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
mute_for_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"mute_for"
Maybe Int
sound_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sound_id"
Maybe Bool
show_preview_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"show_preview"
Maybe Bool
use_default_mute_stories_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"use_default_mute_stories"
Maybe Bool
mute_stories_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"mute_stories"
Maybe Int
story_sound_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"story_sound_id"
Maybe Bool
show_story_sender_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"show_story_sender"
Maybe Bool
disable_pinned_message_notifications_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"disable_pinned_message_notifications"
Maybe Bool
disable_mention_notifications_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"disable_mention_notifications"
ScopeNotificationSettings -> Parser ScopeNotificationSettings
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ScopeNotificationSettings -> Parser ScopeNotificationSettings)
-> ScopeNotificationSettings -> Parser ScopeNotificationSettings
forall a b. (a -> b) -> a -> b
$ ScopeNotificationSettings
{ mute_for :: Maybe Int
mute_for = Maybe Int
mute_for_
, sound_id :: Maybe Int
sound_id = Maybe Int
sound_id_
, show_preview :: Maybe Bool
show_preview = Maybe Bool
show_preview_
, use_default_mute_stories :: Maybe Bool
use_default_mute_stories = Maybe Bool
use_default_mute_stories_
, mute_stories :: Maybe Bool
mute_stories = Maybe Bool
mute_stories_
, story_sound_id :: Maybe Int
story_sound_id = Maybe Int
story_sound_id_
, show_story_sender :: Maybe Bool
show_story_sender = Maybe Bool
show_story_sender_
, disable_pinned_message_notifications :: Maybe Bool
disable_pinned_message_notifications = Maybe Bool
disable_pinned_message_notifications_
, disable_mention_notifications :: Maybe Bool
disable_mention_notifications = Maybe Bool
disable_mention_notifications_
}
parseJSON Value
_ = Parser ScopeNotificationSettings
forall a. Monoid a => a
mempty
instance AT.ToJSON ScopeNotificationSettings where
toJSON :: ScopeNotificationSettings -> Value
toJSON ScopeNotificationSettings
{ mute_for :: ScopeNotificationSettings -> Maybe Int
mute_for = Maybe Int
mute_for_
, sound_id :: ScopeNotificationSettings -> Maybe Int
sound_id = Maybe Int
sound_id_
, show_preview :: ScopeNotificationSettings -> Maybe Bool
show_preview = Maybe Bool
show_preview_
, use_default_mute_stories :: ScopeNotificationSettings -> Maybe Bool
use_default_mute_stories = Maybe Bool
use_default_mute_stories_
, mute_stories :: ScopeNotificationSettings -> Maybe Bool
mute_stories = Maybe Bool
mute_stories_
, story_sound_id :: ScopeNotificationSettings -> Maybe Int
story_sound_id = Maybe Int
story_sound_id_
, show_story_sender :: ScopeNotificationSettings -> Maybe Bool
show_story_sender = Maybe Bool
show_story_sender_
, disable_pinned_message_notifications :: ScopeNotificationSettings -> Maybe Bool
disable_pinned_message_notifications = Maybe Bool
disable_pinned_message_notifications_
, disable_mention_notifications :: ScopeNotificationSettings -> Maybe Bool
disable_mention_notifications = Maybe Bool
disable_mention_notifications_
}
= [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
"scopeNotificationSettings"
, Key
"mute_for" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
mute_for_
, Key
"sound_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64 Maybe Int
sound_id_
, Key
"show_preview" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
show_preview_
, Key
"use_default_mute_stories" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
use_default_mute_stories_
, Key
"mute_stories" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
mute_stories_
, Key
"story_sound_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64 Maybe Int
story_sound_id_
, Key
"show_story_sender" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
show_story_sender_
, Key
"disable_pinned_message_notifications" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
disable_pinned_message_notifications_
, Key
"disable_mention_notifications" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
disable_mention_notifications_
]
defaultScopeNotificationSettings :: ScopeNotificationSettings
defaultScopeNotificationSettings :: ScopeNotificationSettings
defaultScopeNotificationSettings =
ScopeNotificationSettings
{ mute_for :: Maybe Int
mute_for = Maybe Int
forall a. Maybe a
Nothing
, sound_id :: Maybe Int
sound_id = Maybe Int
forall a. Maybe a
Nothing
, show_preview :: Maybe Bool
show_preview = Maybe Bool
forall a. Maybe a
Nothing
, use_default_mute_stories :: Maybe Bool
use_default_mute_stories = Maybe Bool
forall a. Maybe a
Nothing
, mute_stories :: Maybe Bool
mute_stories = Maybe Bool
forall a. Maybe a
Nothing
, story_sound_id :: Maybe Int
story_sound_id = Maybe Int
forall a. Maybe a
Nothing
, show_story_sender :: Maybe Bool
show_story_sender = Maybe Bool
forall a. Maybe a
Nothing
, disable_pinned_message_notifications :: Maybe Bool
disable_pinned_message_notifications = Maybe Bool
forall a. Maybe a
Nothing
, disable_mention_notifications :: Maybe Bool
disable_mention_notifications = Maybe Bool
forall a. Maybe a
Nothing
}