module TD.Data.PremiumState
(PremiumState(..)) 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.FormattedText as FormattedText
import qualified TD.Data.PremiumStatePaymentOption as PremiumStatePaymentOption
import qualified TD.Data.PremiumFeaturePromotionAnimation as PremiumFeaturePromotionAnimation
import qualified TD.Data.BusinessFeaturePromotionAnimation as BusinessFeaturePromotionAnimation
data PremiumState
= PremiumState
{ PremiumState -> Maybe FormattedText
state :: Maybe FormattedText.FormattedText
, PremiumState -> Maybe [PremiumStatePaymentOption]
payment_options :: Maybe [PremiumStatePaymentOption.PremiumStatePaymentOption]
, PremiumState -> Maybe [PremiumFeaturePromotionAnimation]
animations :: Maybe [PremiumFeaturePromotionAnimation.PremiumFeaturePromotionAnimation]
, PremiumState -> Maybe [BusinessFeaturePromotionAnimation]
business_animations :: Maybe [BusinessFeaturePromotionAnimation.BusinessFeaturePromotionAnimation]
}
deriving (PremiumState -> PremiumState -> Bool
(PremiumState -> PremiumState -> Bool)
-> (PremiumState -> PremiumState -> Bool) -> Eq PremiumState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PremiumState -> PremiumState -> Bool
== :: PremiumState -> PremiumState -> Bool
$c/= :: PremiumState -> PremiumState -> Bool
/= :: PremiumState -> PremiumState -> Bool
Eq, Int -> PremiumState -> ShowS
[PremiumState] -> ShowS
PremiumState -> String
(Int -> PremiumState -> ShowS)
-> (PremiumState -> String)
-> ([PremiumState] -> ShowS)
-> Show PremiumState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PremiumState -> ShowS
showsPrec :: Int -> PremiumState -> ShowS
$cshow :: PremiumState -> String
show :: PremiumState -> String
$cshowList :: [PremiumState] -> ShowS
showList :: [PremiumState] -> ShowS
Show)
instance I.ShortShow PremiumState where
shortShow :: PremiumState -> String
shortShow PremiumState
{ state :: PremiumState -> Maybe FormattedText
state = Maybe FormattedText
state_
, payment_options :: PremiumState -> Maybe [PremiumStatePaymentOption]
payment_options = Maybe [PremiumStatePaymentOption]
payment_options_
, animations :: PremiumState -> Maybe [PremiumFeaturePromotionAnimation]
animations = Maybe [PremiumFeaturePromotionAnimation]
animations_
, business_animations :: PremiumState -> Maybe [BusinessFeaturePromotionAnimation]
business_animations = Maybe [BusinessFeaturePromotionAnimation]
business_animations_
}
= String
"PremiumState"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"state" String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
state_
, String
"payment_options" String -> Maybe [PremiumStatePaymentOption] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PremiumStatePaymentOption]
payment_options_
, String
"animations" String -> Maybe [PremiumFeaturePromotionAnimation] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PremiumFeaturePromotionAnimation]
animations_
, String
"business_animations" String -> Maybe [BusinessFeaturePromotionAnimation] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [BusinessFeaturePromotionAnimation]
business_animations_
]
instance AT.FromJSON PremiumState where
parseJSON :: Value -> Parser PremiumState
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
"premiumState" -> Value -> Parser PremiumState
parsePremiumState Value
v
String
_ -> Parser PremiumState
forall a. Monoid a => a
mempty
where
parsePremiumState :: A.Value -> AT.Parser PremiumState
parsePremiumState :: Value -> Parser PremiumState
parsePremiumState = String
-> (Object -> Parser PremiumState) -> Value -> Parser PremiumState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PremiumState" ((Object -> Parser PremiumState) -> Value -> Parser PremiumState)
-> (Object -> Parser PremiumState) -> Value -> Parser PremiumState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe FormattedText
state_ <- Object
o Object -> Key -> Parser (Maybe FormattedText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"state"
Maybe [PremiumStatePaymentOption]
payment_options_ <- Object
o Object -> Key -> Parser (Maybe [PremiumStatePaymentOption])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"payment_options"
Maybe [PremiumFeaturePromotionAnimation]
animations_ <- Object
o Object -> Key -> Parser (Maybe [PremiumFeaturePromotionAnimation])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"animations"
Maybe [BusinessFeaturePromotionAnimation]
business_animations_ <- Object
o Object -> Key -> Parser (Maybe [BusinessFeaturePromotionAnimation])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"business_animations"
PremiumState -> Parser PremiumState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PremiumState -> Parser PremiumState)
-> PremiumState -> Parser PremiumState
forall a b. (a -> b) -> a -> b
$ PremiumState
{ state :: Maybe FormattedText
state = Maybe FormattedText
state_
, payment_options :: Maybe [PremiumStatePaymentOption]
payment_options = Maybe [PremiumStatePaymentOption]
payment_options_
, animations :: Maybe [PremiumFeaturePromotionAnimation]
animations = Maybe [PremiumFeaturePromotionAnimation]
animations_
, business_animations :: Maybe [BusinessFeaturePromotionAnimation]
business_animations = Maybe [BusinessFeaturePromotionAnimation]
business_animations_
}
parseJSON Value
_ = Parser PremiumState
forall a. Monoid a => a
mempty