module TD.Data.ProfileAccentColors
  (ProfileAccentColors(..)) where

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

data ProfileAccentColors
  = ProfileAccentColors -- ^ Contains information about supported accent colors for user profile photo background in RGB format
    { ProfileAccentColors -> Maybe [Int]
palette_colors    :: Maybe [Int] -- ^ The list of 1-2 colors in RGB format, describing the colors, as expected to be shown in the color palette settings
    , ProfileAccentColors -> Maybe [Int]
background_colors :: Maybe [Int] -- ^ The list of 1-2 colors in RGB format, describing the colors, as expected to be used for the profile photo background
    , ProfileAccentColors -> Maybe [Int]
story_colors      :: Maybe [Int] -- ^ The list of 2 colors in RGB format, describing the colors of the gradient to be used for the unread active story indicator around profile photo
    }
  deriving (ProfileAccentColors -> ProfileAccentColors -> Bool
(ProfileAccentColors -> ProfileAccentColors -> Bool)
-> (ProfileAccentColors -> ProfileAccentColors -> Bool)
-> Eq ProfileAccentColors
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProfileAccentColors -> ProfileAccentColors -> Bool
== :: ProfileAccentColors -> ProfileAccentColors -> Bool
$c/= :: ProfileAccentColors -> ProfileAccentColors -> Bool
/= :: ProfileAccentColors -> ProfileAccentColors -> Bool
Eq, Int -> ProfileAccentColors -> ShowS
[ProfileAccentColors] -> ShowS
ProfileAccentColors -> String
(Int -> ProfileAccentColors -> ShowS)
-> (ProfileAccentColors -> String)
-> ([ProfileAccentColors] -> ShowS)
-> Show ProfileAccentColors
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProfileAccentColors -> ShowS
showsPrec :: Int -> ProfileAccentColors -> ShowS
$cshow :: ProfileAccentColors -> String
show :: ProfileAccentColors -> String
$cshowList :: [ProfileAccentColors] -> ShowS
showList :: [ProfileAccentColors] -> ShowS
Show)

instance I.ShortShow ProfileAccentColors where
  shortShow :: ProfileAccentColors -> String
shortShow ProfileAccentColors
    { palette_colors :: ProfileAccentColors -> Maybe [Int]
palette_colors    = Maybe [Int]
palette_colors_
    , background_colors :: ProfileAccentColors -> Maybe [Int]
background_colors = Maybe [Int]
background_colors_
    , story_colors :: ProfileAccentColors -> Maybe [Int]
story_colors      = Maybe [Int]
story_colors_
    }
      = String
"ProfileAccentColors"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"palette_colors"    String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
palette_colors_
        , String
"background_colors" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
background_colors_
        , String
"story_colors"      String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
story_colors_
        ]

instance AT.FromJSON ProfileAccentColors where
  parseJSON :: Value -> Parser ProfileAccentColors
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
"profileAccentColors" -> Value -> Parser ProfileAccentColors
parseProfileAccentColors Value
v
      String
_                     -> Parser ProfileAccentColors
forall a. Monoid a => a
mempty
    
    where
      parseProfileAccentColors :: A.Value -> AT.Parser ProfileAccentColors
      parseProfileAccentColors :: Value -> Parser ProfileAccentColors
parseProfileAccentColors = String
-> (Object -> Parser ProfileAccentColors)
-> Value
-> Parser ProfileAccentColors
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ProfileAccentColors" ((Object -> Parser ProfileAccentColors)
 -> Value -> Parser ProfileAccentColors)
-> (Object -> Parser ProfileAccentColors)
-> Value
-> Parser ProfileAccentColors
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe [Int]
palette_colors_    <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"palette_colors"
        Maybe [Int]
background_colors_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"background_colors"
        Maybe [Int]
story_colors_      <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"story_colors"
        ProfileAccentColors -> Parser ProfileAccentColors
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ProfileAccentColors -> Parser ProfileAccentColors)
-> ProfileAccentColors -> Parser ProfileAccentColors
forall a b. (a -> b) -> a -> b
$ ProfileAccentColors
          { palette_colors :: Maybe [Int]
palette_colors    = Maybe [Int]
palette_colors_
          , background_colors :: Maybe [Int]
background_colors = Maybe [Int]
background_colors_
          , story_colors :: Maybe [Int]
story_colors      = Maybe [Int]
story_colors_
          }
  parseJSON Value
_ = Parser ProfileAccentColors
forall a. Monoid a => a
mempty