module TD.Data.PremiumGiftCodeInfo
(PremiumGiftCodeInfo(..)) 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.MessageSender as MessageSender
data PremiumGiftCodeInfo
= PremiumGiftCodeInfo
{ PremiumGiftCodeInfo -> Maybe MessageSender
creator_id :: Maybe MessageSender.MessageSender
, PremiumGiftCodeInfo -> Maybe Int
creation_date :: Maybe Int
, PremiumGiftCodeInfo -> Maybe Bool
is_from_giveaway :: Maybe Bool
, PremiumGiftCodeInfo -> Maybe Int
giveaway_message_id :: Maybe Int
, PremiumGiftCodeInfo -> Maybe Int
month_count :: Maybe Int
, PremiumGiftCodeInfo -> Maybe Int
user_id :: Maybe Int
, PremiumGiftCodeInfo -> Maybe Int
use_date :: Maybe Int
}
deriving (PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool
(PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool)
-> (PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool)
-> Eq PremiumGiftCodeInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool
== :: PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool
$c/= :: PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool
/= :: PremiumGiftCodeInfo -> PremiumGiftCodeInfo -> Bool
Eq, Int -> PremiumGiftCodeInfo -> ShowS
[PremiumGiftCodeInfo] -> ShowS
PremiumGiftCodeInfo -> String
(Int -> PremiumGiftCodeInfo -> ShowS)
-> (PremiumGiftCodeInfo -> String)
-> ([PremiumGiftCodeInfo] -> ShowS)
-> Show PremiumGiftCodeInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PremiumGiftCodeInfo -> ShowS
showsPrec :: Int -> PremiumGiftCodeInfo -> ShowS
$cshow :: PremiumGiftCodeInfo -> String
show :: PremiumGiftCodeInfo -> String
$cshowList :: [PremiumGiftCodeInfo] -> ShowS
showList :: [PremiumGiftCodeInfo] -> ShowS
Show)
instance I.ShortShow PremiumGiftCodeInfo where
shortShow :: PremiumGiftCodeInfo -> String
shortShow PremiumGiftCodeInfo
{ creator_id :: PremiumGiftCodeInfo -> Maybe MessageSender
creator_id = Maybe MessageSender
creator_id_
, creation_date :: PremiumGiftCodeInfo -> Maybe Int
creation_date = Maybe Int
creation_date_
, is_from_giveaway :: PremiumGiftCodeInfo -> Maybe Bool
is_from_giveaway = Maybe Bool
is_from_giveaway_
, giveaway_message_id :: PremiumGiftCodeInfo -> Maybe Int
giveaway_message_id = Maybe Int
giveaway_message_id_
, month_count :: PremiumGiftCodeInfo -> Maybe Int
month_count = Maybe Int
month_count_
, user_id :: PremiumGiftCodeInfo -> Maybe Int
user_id = Maybe Int
user_id_
, use_date :: PremiumGiftCodeInfo -> Maybe Int
use_date = Maybe Int
use_date_
}
= String
"PremiumGiftCodeInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"creator_id" String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
creator_id_
, String
"creation_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
creation_date_
, String
"is_from_giveaway" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_from_giveaway_
, String
"giveaway_message_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
giveaway_message_id_
, String
"month_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
month_count_
, String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
, String
"use_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
use_date_
]
instance AT.FromJSON PremiumGiftCodeInfo where
parseJSON :: Value -> Parser PremiumGiftCodeInfo
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
"premiumGiftCodeInfo" -> Value -> Parser PremiumGiftCodeInfo
parsePremiumGiftCodeInfo Value
v
String
_ -> Parser PremiumGiftCodeInfo
forall a. Monoid a => a
mempty
where
parsePremiumGiftCodeInfo :: A.Value -> AT.Parser PremiumGiftCodeInfo
parsePremiumGiftCodeInfo :: Value -> Parser PremiumGiftCodeInfo
parsePremiumGiftCodeInfo = String
-> (Object -> Parser PremiumGiftCodeInfo)
-> Value
-> Parser PremiumGiftCodeInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PremiumGiftCodeInfo" ((Object -> Parser PremiumGiftCodeInfo)
-> Value -> Parser PremiumGiftCodeInfo)
-> (Object -> Parser PremiumGiftCodeInfo)
-> Value
-> Parser PremiumGiftCodeInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe MessageSender
creator_id_ <- Object
o Object -> Key -> Parser (Maybe MessageSender)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"creator_id"
Maybe Int
creation_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"creation_date"
Maybe Bool
is_from_giveaway_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_from_giveaway"
Maybe Int
giveaway_message_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"giveaway_message_id"
Maybe Int
month_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"month_count"
Maybe Int
user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_id"
Maybe Int
use_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"use_date"
PremiumGiftCodeInfo -> Parser PremiumGiftCodeInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PremiumGiftCodeInfo -> Parser PremiumGiftCodeInfo)
-> PremiumGiftCodeInfo -> Parser PremiumGiftCodeInfo
forall a b. (a -> b) -> a -> b
$ PremiumGiftCodeInfo
{ creator_id :: Maybe MessageSender
creator_id = Maybe MessageSender
creator_id_
, creation_date :: Maybe Int
creation_date = Maybe Int
creation_date_
, is_from_giveaway :: Maybe Bool
is_from_giveaway = Maybe Bool
is_from_giveaway_
, giveaway_message_id :: Maybe Int
giveaway_message_id = Maybe Int
giveaway_message_id_
, month_count :: Maybe Int
month_count = Maybe Int
month_count_
, user_id :: Maybe Int
user_id = Maybe Int
user_id_
, use_date :: Maybe Int
use_date = Maybe Int
use_date_
}
parseJSON Value
_ = Parser PremiumGiftCodeInfo
forall a. Monoid a => a
mempty