module TD.Data.UpgradedGiftColors
  (UpgradedGiftColors(..)) where

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

data UpgradedGiftColors
  = UpgradedGiftColors -- ^ Contains information about color scheme for user's name, background of empty chat photo, replies to messages and link previews
    { UpgradedGiftColors -> Maybe Int
_id                      :: Maybe Int   -- ^ Unique identifier of the upgraded gift colors
    , UpgradedGiftColors -> Maybe Int
model_custom_emoji_id    :: Maybe Int   -- ^ Custom emoji identifier of the model of the upgraded gift
    , UpgradedGiftColors -> Maybe Int
symbol_custom_emoji_id   :: Maybe Int   -- ^ Custom emoji identifier of the symbol of the upgraded gift
    , UpgradedGiftColors -> Maybe Int
light_theme_accent_color :: Maybe Int   -- ^ Accent color to use in light themes in RGB format
    , UpgradedGiftColors -> Maybe [Int]
light_theme_colors       :: Maybe [Int] -- ^ The list of 1-3 colors in RGB format, describing the accent color, as expected to be shown in light themes
    , UpgradedGiftColors -> Maybe Int
dark_theme_accent_color  :: Maybe Int   -- ^ Accent color to use in dark themes in RGB format
    , UpgradedGiftColors -> Maybe [Int]
dark_theme_colors        :: Maybe [Int] -- ^ The list of 1-3 colors in RGB format, describing the accent color, as expected to be shown in dark themes
    }
  deriving (UpgradedGiftColors -> UpgradedGiftColors -> Bool
(UpgradedGiftColors -> UpgradedGiftColors -> Bool)
-> (UpgradedGiftColors -> UpgradedGiftColors -> Bool)
-> Eq UpgradedGiftColors
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpgradedGiftColors -> UpgradedGiftColors -> Bool
== :: UpgradedGiftColors -> UpgradedGiftColors -> Bool
$c/= :: UpgradedGiftColors -> UpgradedGiftColors -> Bool
/= :: UpgradedGiftColors -> UpgradedGiftColors -> Bool
Eq, Int -> UpgradedGiftColors -> ShowS
[UpgradedGiftColors] -> ShowS
UpgradedGiftColors -> String
(Int -> UpgradedGiftColors -> ShowS)
-> (UpgradedGiftColors -> String)
-> ([UpgradedGiftColors] -> ShowS)
-> Show UpgradedGiftColors
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpgradedGiftColors -> ShowS
showsPrec :: Int -> UpgradedGiftColors -> ShowS
$cshow :: UpgradedGiftColors -> String
show :: UpgradedGiftColors -> String
$cshowList :: [UpgradedGiftColors] -> ShowS
showList :: [UpgradedGiftColors] -> ShowS
Show)

instance I.ShortShow UpgradedGiftColors where
  shortShow :: UpgradedGiftColors -> String
shortShow UpgradedGiftColors
    { _id :: UpgradedGiftColors -> Maybe Int
_id                      = Maybe Int
_id_
    , model_custom_emoji_id :: UpgradedGiftColors -> Maybe Int
model_custom_emoji_id    = Maybe Int
model_custom_emoji_id_
    , symbol_custom_emoji_id :: UpgradedGiftColors -> Maybe Int
symbol_custom_emoji_id   = Maybe Int
symbol_custom_emoji_id_
    , light_theme_accent_color :: UpgradedGiftColors -> Maybe Int
light_theme_accent_color = Maybe Int
light_theme_accent_color_
    , light_theme_colors :: UpgradedGiftColors -> Maybe [Int]
light_theme_colors       = Maybe [Int]
light_theme_colors_
    , dark_theme_accent_color :: UpgradedGiftColors -> Maybe Int
dark_theme_accent_color  = Maybe Int
dark_theme_accent_color_
    , dark_theme_colors :: UpgradedGiftColors -> Maybe [Int]
dark_theme_colors        = Maybe [Int]
dark_theme_colors_
    }
      = String
"UpgradedGiftColors"
        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
"model_custom_emoji_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
model_custom_emoji_id_
        , String
"symbol_custom_emoji_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
symbol_custom_emoji_id_
        , String
"light_theme_accent_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
light_theme_accent_color_
        , 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_accent_color"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
dark_theme_accent_color_
        , String
"dark_theme_colors"        String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
dark_theme_colors_
        ]

instance AT.FromJSON UpgradedGiftColors where
  parseJSON :: Value -> Parser UpgradedGiftColors
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
"upgradedGiftColors" -> Value -> Parser UpgradedGiftColors
parseUpgradedGiftColors Value
v
      String
_                    -> Parser UpgradedGiftColors
forall a. Monoid a => a
mempty
    
    where
      parseUpgradedGiftColors :: A.Value -> AT.Parser UpgradedGiftColors
      parseUpgradedGiftColors :: Value -> Parser UpgradedGiftColors
parseUpgradedGiftColors = String
-> (Object -> Parser UpgradedGiftColors)
-> Value
-> Parser UpgradedGiftColors
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UpgradedGiftColors" ((Object -> Parser UpgradedGiftColors)
 -> Value -> Parser UpgradedGiftColors)
-> (Object -> Parser UpgradedGiftColors)
-> Value
-> Parser UpgradedGiftColors
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
_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
"id"
        Maybe Int
model_custom_emoji_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
"model_custom_emoji_id"
        Maybe Int
symbol_custom_emoji_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
"symbol_custom_emoji_id"
        Maybe Int
light_theme_accent_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"light_theme_accent_color"
        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_accent_color_  <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"dark_theme_accent_color"
        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"
        UpgradedGiftColors -> Parser UpgradedGiftColors
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UpgradedGiftColors -> Parser UpgradedGiftColors)
-> UpgradedGiftColors -> Parser UpgradedGiftColors
forall a b. (a -> b) -> a -> b
$ UpgradedGiftColors
          { _id :: Maybe Int
_id                      = Maybe Int
_id_
          , model_custom_emoji_id :: Maybe Int
model_custom_emoji_id    = Maybe Int
model_custom_emoji_id_
          , symbol_custom_emoji_id :: Maybe Int
symbol_custom_emoji_id   = Maybe Int
symbol_custom_emoji_id_
          , light_theme_accent_color :: Maybe Int
light_theme_accent_color = Maybe Int
light_theme_accent_color_
          , light_theme_colors :: Maybe [Int]
light_theme_colors       = Maybe [Int]
light_theme_colors_
          , dark_theme_accent_color :: Maybe Int
dark_theme_accent_color  = Maybe Int
dark_theme_accent_color_
          , dark_theme_colors :: Maybe [Int]
dark_theme_colors        = Maybe [Int]
dark_theme_colors_
          }
  parseJSON Value
_ = Parser UpgradedGiftColors
forall a. Monoid a => a
mempty