module TD.Data.ChatBoostStatus
(ChatBoostStatus(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.PrepaidGiveaway as PrepaidGiveaway
data ChatBoostStatus
= ChatBoostStatus
{ ChatBoostStatus -> Maybe Text
boost_url :: Maybe T.Text
, ChatBoostStatus -> Maybe [Int]
applied_slot_ids :: Maybe [Int]
, ChatBoostStatus -> Maybe Int
level :: Maybe Int
, ChatBoostStatus -> Maybe Int
gift_code_boost_count :: Maybe Int
, ChatBoostStatus -> Maybe Int
boost_count :: Maybe Int
, ChatBoostStatus -> Maybe Int
current_level_boost_count :: Maybe Int
, ChatBoostStatus -> Maybe Int
next_level_boost_count :: Maybe Int
, ChatBoostStatus -> Maybe Int
premium_member_count :: Maybe Int
, ChatBoostStatus -> Maybe Double
premium_member_percentage :: Maybe Double
, ChatBoostStatus -> Maybe [PrepaidGiveaway]
prepaid_giveaways :: Maybe [PrepaidGiveaway.PrepaidGiveaway]
}
deriving (ChatBoostStatus -> ChatBoostStatus -> Bool
(ChatBoostStatus -> ChatBoostStatus -> Bool)
-> (ChatBoostStatus -> ChatBoostStatus -> Bool)
-> Eq ChatBoostStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatBoostStatus -> ChatBoostStatus -> Bool
== :: ChatBoostStatus -> ChatBoostStatus -> Bool
$c/= :: ChatBoostStatus -> ChatBoostStatus -> Bool
/= :: ChatBoostStatus -> ChatBoostStatus -> Bool
Eq, Int -> ChatBoostStatus -> ShowS
[ChatBoostStatus] -> ShowS
ChatBoostStatus -> String
(Int -> ChatBoostStatus -> ShowS)
-> (ChatBoostStatus -> String)
-> ([ChatBoostStatus] -> ShowS)
-> Show ChatBoostStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatBoostStatus -> ShowS
showsPrec :: Int -> ChatBoostStatus -> ShowS
$cshow :: ChatBoostStatus -> String
show :: ChatBoostStatus -> String
$cshowList :: [ChatBoostStatus] -> ShowS
showList :: [ChatBoostStatus] -> ShowS
Show)
instance I.ShortShow ChatBoostStatus where
shortShow :: ChatBoostStatus -> String
shortShow ChatBoostStatus
{ boost_url :: ChatBoostStatus -> Maybe Text
boost_url = Maybe Text
boost_url_
, applied_slot_ids :: ChatBoostStatus -> Maybe [Int]
applied_slot_ids = Maybe [Int]
applied_slot_ids_
, level :: ChatBoostStatus -> Maybe Int
level = Maybe Int
level_
, gift_code_boost_count :: ChatBoostStatus -> Maybe Int
gift_code_boost_count = Maybe Int
gift_code_boost_count_
, boost_count :: ChatBoostStatus -> Maybe Int
boost_count = Maybe Int
boost_count_
, current_level_boost_count :: ChatBoostStatus -> Maybe Int
current_level_boost_count = Maybe Int
current_level_boost_count_
, next_level_boost_count :: ChatBoostStatus -> Maybe Int
next_level_boost_count = Maybe Int
next_level_boost_count_
, premium_member_count :: ChatBoostStatus -> Maybe Int
premium_member_count = Maybe Int
premium_member_count_
, premium_member_percentage :: ChatBoostStatus -> Maybe Double
premium_member_percentage = Maybe Double
premium_member_percentage_
, prepaid_giveaways :: ChatBoostStatus -> Maybe [PrepaidGiveaway]
prepaid_giveaways = Maybe [PrepaidGiveaway]
prepaid_giveaways_
}
= String
"ChatBoostStatus"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"boost_url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
boost_url_
, String
"applied_slot_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
applied_slot_ids_
, String
"level" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
level_
, String
"gift_code_boost_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
gift_code_boost_count_
, String
"boost_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
boost_count_
, String
"current_level_boost_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
current_level_boost_count_
, String
"next_level_boost_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
next_level_boost_count_
, String
"premium_member_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
premium_member_count_
, String
"premium_member_percentage" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
premium_member_percentage_
, String
"prepaid_giveaways" String -> Maybe [PrepaidGiveaway] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PrepaidGiveaway]
prepaid_giveaways_
]
instance AT.FromJSON ChatBoostStatus where
parseJSON :: Value -> Parser ChatBoostStatus
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
"chatBoostStatus" -> Value -> Parser ChatBoostStatus
parseChatBoostStatus Value
v
String
_ -> Parser ChatBoostStatus
forall a. Monoid a => a
mempty
where
parseChatBoostStatus :: A.Value -> AT.Parser ChatBoostStatus
parseChatBoostStatus :: Value -> Parser ChatBoostStatus
parseChatBoostStatus = String
-> (Object -> Parser ChatBoostStatus)
-> Value
-> Parser ChatBoostStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatBoostStatus" ((Object -> Parser ChatBoostStatus)
-> Value -> Parser ChatBoostStatus)
-> (Object -> Parser ChatBoostStatus)
-> Value
-> Parser ChatBoostStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
boost_url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"boost_url"
Maybe [Int]
applied_slot_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"applied_slot_ids"
Maybe Int
level_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"level"
Maybe Int
gift_code_boost_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"gift_code_boost_count"
Maybe Int
boost_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"boost_count"
Maybe Int
current_level_boost_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"current_level_boost_count"
Maybe Int
next_level_boost_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_level_boost_count"
Maybe Int
premium_member_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"premium_member_count"
Maybe Double
premium_member_percentage_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"premium_member_percentage"
Maybe [PrepaidGiveaway]
prepaid_giveaways_ <- Object
o Object -> Key -> Parser (Maybe [PrepaidGiveaway])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"prepaid_giveaways"
ChatBoostStatus -> Parser ChatBoostStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatBoostStatus -> Parser ChatBoostStatus)
-> ChatBoostStatus -> Parser ChatBoostStatus
forall a b. (a -> b) -> a -> b
$ ChatBoostStatus
{ boost_url :: Maybe Text
boost_url = Maybe Text
boost_url_
, applied_slot_ids :: Maybe [Int]
applied_slot_ids = Maybe [Int]
applied_slot_ids_
, level :: Maybe Int
level = Maybe Int
level_
, gift_code_boost_count :: Maybe Int
gift_code_boost_count = Maybe Int
gift_code_boost_count_
, boost_count :: Maybe Int
boost_count = Maybe Int
boost_count_
, current_level_boost_count :: Maybe Int
current_level_boost_count = Maybe Int
current_level_boost_count_
, next_level_boost_count :: Maybe Int
next_level_boost_count = Maybe Int
next_level_boost_count_
, premium_member_count :: Maybe Int
premium_member_count = Maybe Int
premium_member_count_
, premium_member_percentage :: Maybe Double
premium_member_percentage = Maybe Double
premium_member_percentage_
, prepaid_giveaways :: Maybe [PrepaidGiveaway]
prepaid_giveaways = Maybe [PrepaidGiveaway]
prepaid_giveaways_
}
parseJSON Value
_ = Parser ChatBoostStatus
forall a. Monoid a => a
mempty