module TD.Data.PremiumFeaturePromotionAnimation
  (PremiumFeaturePromotionAnimation(..)) 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.PremiumFeature as PremiumFeature
import qualified TD.Data.Animation as Animation

data PremiumFeaturePromotionAnimation
  = PremiumFeaturePromotionAnimation -- ^ Describes a promotion animation for a Premium feature
    { PremiumFeaturePromotionAnimation -> Maybe PremiumFeature
feature   :: Maybe PremiumFeature.PremiumFeature -- ^ Premium feature
    , PremiumFeaturePromotionAnimation -> Maybe Animation
animation :: Maybe Animation.Animation           -- ^ Promotion animation for the feature
    }
  deriving (PremiumFeaturePromotionAnimation
-> PremiumFeaturePromotionAnimation -> Bool
(PremiumFeaturePromotionAnimation
 -> PremiumFeaturePromotionAnimation -> Bool)
-> (PremiumFeaturePromotionAnimation
    -> PremiumFeaturePromotionAnimation -> Bool)
-> Eq PremiumFeaturePromotionAnimation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PremiumFeaturePromotionAnimation
-> PremiumFeaturePromotionAnimation -> Bool
== :: PremiumFeaturePromotionAnimation
-> PremiumFeaturePromotionAnimation -> Bool
$c/= :: PremiumFeaturePromotionAnimation
-> PremiumFeaturePromotionAnimation -> Bool
/= :: PremiumFeaturePromotionAnimation
-> PremiumFeaturePromotionAnimation -> Bool
Eq, Int -> PremiumFeaturePromotionAnimation -> ShowS
[PremiumFeaturePromotionAnimation] -> ShowS
PremiumFeaturePromotionAnimation -> String
(Int -> PremiumFeaturePromotionAnimation -> ShowS)
-> (PremiumFeaturePromotionAnimation -> String)
-> ([PremiumFeaturePromotionAnimation] -> ShowS)
-> Show PremiumFeaturePromotionAnimation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PremiumFeaturePromotionAnimation -> ShowS
showsPrec :: Int -> PremiumFeaturePromotionAnimation -> ShowS
$cshow :: PremiumFeaturePromotionAnimation -> String
show :: PremiumFeaturePromotionAnimation -> String
$cshowList :: [PremiumFeaturePromotionAnimation] -> ShowS
showList :: [PremiumFeaturePromotionAnimation] -> ShowS
Show)

instance I.ShortShow PremiumFeaturePromotionAnimation where
  shortShow :: PremiumFeaturePromotionAnimation -> String
shortShow PremiumFeaturePromotionAnimation
    { feature :: PremiumFeaturePromotionAnimation -> Maybe PremiumFeature
feature   = Maybe PremiumFeature
feature_
    , animation :: PremiumFeaturePromotionAnimation -> Maybe Animation
animation = Maybe Animation
animation_
    }
      = String
"PremiumFeaturePromotionAnimation"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"feature"   String -> Maybe PremiumFeature -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe PremiumFeature
feature_
        , String
"animation" String -> Maybe Animation -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Animation
animation_
        ]

instance AT.FromJSON PremiumFeaturePromotionAnimation where
  parseJSON :: Value -> Parser PremiumFeaturePromotionAnimation
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
"premiumFeaturePromotionAnimation" -> Value -> Parser PremiumFeaturePromotionAnimation
parsePremiumFeaturePromotionAnimation Value
v
      String
_                                  -> Parser PremiumFeaturePromotionAnimation
forall a. Monoid a => a
mempty
    
    where
      parsePremiumFeaturePromotionAnimation :: A.Value -> AT.Parser PremiumFeaturePromotionAnimation
      parsePremiumFeaturePromotionAnimation :: Value -> Parser PremiumFeaturePromotionAnimation
parsePremiumFeaturePromotionAnimation = String
-> (Object -> Parser PremiumFeaturePromotionAnimation)
-> Value
-> Parser PremiumFeaturePromotionAnimation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PremiumFeaturePromotionAnimation" ((Object -> Parser PremiumFeaturePromotionAnimation)
 -> Value -> Parser PremiumFeaturePromotionAnimation)
-> (Object -> Parser PremiumFeaturePromotionAnimation)
-> Value
-> Parser PremiumFeaturePromotionAnimation
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe PremiumFeature
feature_   <- Object
o Object -> Key -> Parser (Maybe PremiumFeature)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"feature"
        Maybe Animation
animation_ <- Object
o Object -> Key -> Parser (Maybe Animation)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"animation"
        PremiumFeaturePromotionAnimation
-> Parser PremiumFeaturePromotionAnimation
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PremiumFeaturePromotionAnimation
 -> Parser PremiumFeaturePromotionAnimation)
-> PremiumFeaturePromotionAnimation
-> Parser PremiumFeaturePromotionAnimation
forall a b. (a -> b) -> a -> b
$ PremiumFeaturePromotionAnimation
          { feature :: Maybe PremiumFeature
feature   = Maybe PremiumFeature
feature_
          , animation :: Maybe Animation
animation = Maybe Animation
animation_
          }
  parseJSON Value
_ = Parser PremiumFeaturePromotionAnimation
forall a. Monoid a => a
mempty