module TD.Data.ProfileShareThemeBackdrops
  (ProfileShareThemeBackdrops(..)) 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.ProfileShareThemeBackdrop as ProfileShareThemeBackdrop

data ProfileShareThemeBackdrops
  = ProfileShareThemeBackdrops -- ^ Contains a list of backdrops, which can be used as a background of a theme of the screen for sharing a link to a user or a chat
    { ProfileShareThemeBackdrops -> Maybe [ProfileShareThemeBackdrop]
backdrops :: Maybe [ProfileShareThemeBackdrop.ProfileShareThemeBackdrop] -- ^ The list of backdrops
    }
  deriving (ProfileShareThemeBackdrops -> ProfileShareThemeBackdrops -> Bool
(ProfileShareThemeBackdrops -> ProfileShareThemeBackdrops -> Bool)
-> (ProfileShareThemeBackdrops
    -> ProfileShareThemeBackdrops -> Bool)
-> Eq ProfileShareThemeBackdrops
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProfileShareThemeBackdrops -> ProfileShareThemeBackdrops -> Bool
== :: ProfileShareThemeBackdrops -> ProfileShareThemeBackdrops -> Bool
$c/= :: ProfileShareThemeBackdrops -> ProfileShareThemeBackdrops -> Bool
/= :: ProfileShareThemeBackdrops -> ProfileShareThemeBackdrops -> Bool
Eq, Int -> ProfileShareThemeBackdrops -> ShowS
[ProfileShareThemeBackdrops] -> ShowS
ProfileShareThemeBackdrops -> String
(Int -> ProfileShareThemeBackdrops -> ShowS)
-> (ProfileShareThemeBackdrops -> String)
-> ([ProfileShareThemeBackdrops] -> ShowS)
-> Show ProfileShareThemeBackdrops
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProfileShareThemeBackdrops -> ShowS
showsPrec :: Int -> ProfileShareThemeBackdrops -> ShowS
$cshow :: ProfileShareThemeBackdrops -> String
show :: ProfileShareThemeBackdrops -> String
$cshowList :: [ProfileShareThemeBackdrops] -> ShowS
showList :: [ProfileShareThemeBackdrops] -> ShowS
Show)

instance I.ShortShow ProfileShareThemeBackdrops where
  shortShow :: ProfileShareThemeBackdrops -> String
shortShow ProfileShareThemeBackdrops
    { backdrops :: ProfileShareThemeBackdrops -> Maybe [ProfileShareThemeBackdrop]
backdrops = Maybe [ProfileShareThemeBackdrop]
backdrops_
    }
      = String
"ProfileShareThemeBackdrops"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"backdrops" String -> Maybe [ProfileShareThemeBackdrop] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ProfileShareThemeBackdrop]
backdrops_
        ]

instance AT.FromJSON ProfileShareThemeBackdrops where
  parseJSON :: Value -> Parser ProfileShareThemeBackdrops
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
"profileShareThemeBackdrops" -> Value -> Parser ProfileShareThemeBackdrops
parseProfileShareThemeBackdrops Value
v
      String
_                            -> Parser ProfileShareThemeBackdrops
forall a. Monoid a => a
mempty
    
    where
      parseProfileShareThemeBackdrops :: A.Value -> AT.Parser ProfileShareThemeBackdrops
      parseProfileShareThemeBackdrops :: Value -> Parser ProfileShareThemeBackdrops
parseProfileShareThemeBackdrops = String
-> (Object -> Parser ProfileShareThemeBackdrops)
-> Value
-> Parser ProfileShareThemeBackdrops
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ProfileShareThemeBackdrops" ((Object -> Parser ProfileShareThemeBackdrops)
 -> Value -> Parser ProfileShareThemeBackdrops)
-> (Object -> Parser ProfileShareThemeBackdrops)
-> Value
-> Parser ProfileShareThemeBackdrops
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe [ProfileShareThemeBackdrop]
backdrops_ <- Object
o Object -> Key -> Parser (Maybe [ProfileShareThemeBackdrop])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"backdrops"
        ProfileShareThemeBackdrops -> Parser ProfileShareThemeBackdrops
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ProfileShareThemeBackdrops -> Parser ProfileShareThemeBackdrops)
-> ProfileShareThemeBackdrops -> Parser ProfileShareThemeBackdrops
forall a b. (a -> b) -> a -> b
$ ProfileShareThemeBackdrops
          { backdrops :: Maybe [ProfileShareThemeBackdrop]
backdrops = Maybe [ProfileShareThemeBackdrop]
backdrops_
          }
  parseJSON Value
_ = Parser ProfileShareThemeBackdrops
forall a. Monoid a => a
mempty