module TD.Data.AccentColor
(AccentColor(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data AccentColor
= AccentColor
{ AccentColor -> Maybe Int
_id :: Maybe Int
, AccentColor -> Maybe Int
built_in_accent_color_id :: Maybe Int
, AccentColor -> Maybe [Int]
light_theme_colors :: Maybe [Int]
, AccentColor -> Maybe [Int]
dark_theme_colors :: Maybe [Int]
, AccentColor -> Maybe Int
min_channel_chat_boost_level :: Maybe Int
}
deriving (AccentColor -> AccentColor -> Bool
(AccentColor -> AccentColor -> Bool)
-> (AccentColor -> AccentColor -> Bool) -> Eq AccentColor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AccentColor -> AccentColor -> Bool
== :: AccentColor -> AccentColor -> Bool
$c/= :: AccentColor -> AccentColor -> Bool
/= :: AccentColor -> AccentColor -> Bool
Eq, Int -> AccentColor -> ShowS
[AccentColor] -> ShowS
AccentColor -> String
(Int -> AccentColor -> ShowS)
-> (AccentColor -> String)
-> ([AccentColor] -> ShowS)
-> Show AccentColor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AccentColor -> ShowS
showsPrec :: Int -> AccentColor -> ShowS
$cshow :: AccentColor -> String
show :: AccentColor -> String
$cshowList :: [AccentColor] -> ShowS
showList :: [AccentColor] -> ShowS
Show)
instance I.ShortShow AccentColor where
shortShow :: AccentColor -> String
shortShow AccentColor
{ _id :: AccentColor -> Maybe Int
_id = Maybe Int
_id_
, built_in_accent_color_id :: AccentColor -> Maybe Int
built_in_accent_color_id = Maybe Int
built_in_accent_color_id_
, light_theme_colors :: AccentColor -> Maybe [Int]
light_theme_colors = Maybe [Int]
light_theme_colors_
, dark_theme_colors :: AccentColor -> Maybe [Int]
dark_theme_colors = Maybe [Int]
dark_theme_colors_
, min_channel_chat_boost_level :: AccentColor -> Maybe Int
min_channel_chat_boost_level = Maybe Int
min_channel_chat_boost_level_
}
= String
"AccentColor"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
_id_
, String
"built_in_accent_color_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
built_in_accent_color_id_
, String
"light_theme_colors" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
light_theme_colors_
, String
"dark_theme_colors" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
dark_theme_colors_
, String
"min_channel_chat_boost_level" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_channel_chat_boost_level_
]
instance AT.FromJSON AccentColor where
parseJSON :: Value -> Parser AccentColor
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
"accentColor" -> Value -> Parser AccentColor
parseAccentColor Value
v
String
_ -> Parser AccentColor
forall a. Monoid a => a
mempty
where
parseAccentColor :: A.Value -> AT.Parser AccentColor
parseAccentColor :: Value -> Parser AccentColor
parseAccentColor = String
-> (Object -> Parser AccentColor) -> Value -> Parser AccentColor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AccentColor" ((Object -> Parser AccentColor) -> Value -> Parser AccentColor)
-> (Object -> Parser AccentColor) -> Value -> Parser AccentColor
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe Int
built_in_accent_color_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"built_in_accent_color_id"
Maybe [Int]
light_theme_colors_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"light_theme_colors"
Maybe [Int]
dark_theme_colors_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"dark_theme_colors"
Maybe Int
min_channel_chat_boost_level_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"min_channel_chat_boost_level"
AccentColor -> Parser AccentColor
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AccentColor -> Parser AccentColor)
-> AccentColor -> Parser AccentColor
forall a b. (a -> b) -> a -> b
$ AccentColor
{ _id :: Maybe Int
_id = Maybe Int
_id_
, built_in_accent_color_id :: Maybe Int
built_in_accent_color_id = Maybe Int
built_in_accent_color_id_
, light_theme_colors :: Maybe [Int]
light_theme_colors = Maybe [Int]
light_theme_colors_
, dark_theme_colors :: Maybe [Int]
dark_theme_colors = Maybe [Int]
dark_theme_colors_
, min_channel_chat_boost_level :: Maybe Int
min_channel_chat_boost_level = Maybe Int
min_channel_chat_boost_level_
}
parseJSON Value
_ = Parser AccentColor
forall a. Monoid a => a
mempty