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