module TD.Data.GiftsForResale
(GiftsForResale(..)) 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.GiftForResale as GiftForResale
import qualified TD.Data.UpgradedGiftModelCount as UpgradedGiftModelCount
import qualified TD.Data.UpgradedGiftSymbolCount as UpgradedGiftSymbolCount
import qualified TD.Data.UpgradedGiftBackdropCount as UpgradedGiftBackdropCount
import qualified Data.Text as T
data GiftsForResale
= GiftsForResale
{ GiftsForResale -> Maybe Int
total_count :: Maybe Int
, GiftsForResale -> Maybe [GiftForResale]
gifts :: Maybe [GiftForResale.GiftForResale]
, GiftsForResale -> Maybe [UpgradedGiftModelCount]
models :: Maybe [UpgradedGiftModelCount.UpgradedGiftModelCount]
, GiftsForResale -> Maybe [UpgradedGiftSymbolCount]
symbols :: Maybe [UpgradedGiftSymbolCount.UpgradedGiftSymbolCount]
, GiftsForResale -> Maybe [UpgradedGiftBackdropCount]
backdrops :: Maybe [UpgradedGiftBackdropCount.UpgradedGiftBackdropCount]
, GiftsForResale -> Maybe Text
next_offset :: Maybe T.Text
}
deriving (GiftsForResale -> GiftsForResale -> Bool
(GiftsForResale -> GiftsForResale -> Bool)
-> (GiftsForResale -> GiftsForResale -> Bool) -> Eq GiftsForResale
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftsForResale -> GiftsForResale -> Bool
== :: GiftsForResale -> GiftsForResale -> Bool
$c/= :: GiftsForResale -> GiftsForResale -> Bool
/= :: GiftsForResale -> GiftsForResale -> Bool
Eq, Int -> GiftsForResale -> ShowS
[GiftsForResale] -> ShowS
GiftsForResale -> String
(Int -> GiftsForResale -> ShowS)
-> (GiftsForResale -> String)
-> ([GiftsForResale] -> ShowS)
-> Show GiftsForResale
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftsForResale -> ShowS
showsPrec :: Int -> GiftsForResale -> ShowS
$cshow :: GiftsForResale -> String
show :: GiftsForResale -> String
$cshowList :: [GiftsForResale] -> ShowS
showList :: [GiftsForResale] -> ShowS
Show)
instance I.ShortShow GiftsForResale where
shortShow :: GiftsForResale -> String
shortShow GiftsForResale
{ total_count :: GiftsForResale -> Maybe Int
total_count = Maybe Int
total_count_
, gifts :: GiftsForResale -> Maybe [GiftForResale]
gifts = Maybe [GiftForResale]
gifts_
, models :: GiftsForResale -> Maybe [UpgradedGiftModelCount]
models = Maybe [UpgradedGiftModelCount]
models_
, symbols :: GiftsForResale -> Maybe [UpgradedGiftSymbolCount]
symbols = Maybe [UpgradedGiftSymbolCount]
symbols_
, backdrops :: GiftsForResale -> Maybe [UpgradedGiftBackdropCount]
backdrops = Maybe [UpgradedGiftBackdropCount]
backdrops_
, next_offset :: GiftsForResale -> Maybe Text
next_offset = Maybe Text
next_offset_
}
= String
"GiftsForResale"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"total_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
total_count_
, String
"gifts" String -> Maybe [GiftForResale] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [GiftForResale]
gifts_
, String
"models" String -> Maybe [UpgradedGiftModelCount] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [UpgradedGiftModelCount]
models_
, String
"symbols" String -> Maybe [UpgradedGiftSymbolCount] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [UpgradedGiftSymbolCount]
symbols_
, String
"backdrops" String -> Maybe [UpgradedGiftBackdropCount] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [UpgradedGiftBackdropCount]
backdrops_
, String
"next_offset" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
next_offset_
]
instance AT.FromJSON GiftsForResale where
parseJSON :: Value -> Parser GiftsForResale
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
"giftsForResale" -> Value -> Parser GiftsForResale
parseGiftsForResale Value
v
String
_ -> Parser GiftsForResale
forall a. Monoid a => a
mempty
where
parseGiftsForResale :: A.Value -> AT.Parser GiftsForResale
parseGiftsForResale :: Value -> Parser GiftsForResale
parseGiftsForResale = String
-> (Object -> Parser GiftsForResale)
-> Value
-> Parser GiftsForResale
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiftsForResale" ((Object -> Parser GiftsForResale)
-> Value -> Parser GiftsForResale)
-> (Object -> Parser GiftsForResale)
-> Value
-> Parser GiftsForResale
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
total_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"total_count"
Maybe [GiftForResale]
gifts_ <- Object
o Object -> Key -> Parser (Maybe [GiftForResale])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"gifts"
Maybe [UpgradedGiftModelCount]
models_ <- Object
o Object -> Key -> Parser (Maybe [UpgradedGiftModelCount])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"models"
Maybe [UpgradedGiftSymbolCount]
symbols_ <- Object
o Object -> Key -> Parser (Maybe [UpgradedGiftSymbolCount])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"symbols"
Maybe [UpgradedGiftBackdropCount]
backdrops_ <- Object
o Object -> Key -> Parser (Maybe [UpgradedGiftBackdropCount])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"backdrops"
Maybe Text
next_offset_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_offset"
GiftsForResale -> Parser GiftsForResale
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiftsForResale -> Parser GiftsForResale)
-> GiftsForResale -> Parser GiftsForResale
forall a b. (a -> b) -> a -> b
$ GiftsForResale
{ total_count :: Maybe Int
total_count = Maybe Int
total_count_
, gifts :: Maybe [GiftForResale]
gifts = Maybe [GiftForResale]
gifts_
, models :: Maybe [UpgradedGiftModelCount]
models = Maybe [UpgradedGiftModelCount]
models_
, symbols :: Maybe [UpgradedGiftSymbolCount]
symbols = Maybe [UpgradedGiftSymbolCount]
symbols_
, backdrops :: Maybe [UpgradedGiftBackdropCount]
backdrops = Maybe [UpgradedGiftBackdropCount]
backdrops_
, next_offset :: Maybe Text
next_offset = Maybe Text
next_offset_
}
parseJSON Value
_ = Parser GiftsForResale
forall a. Monoid a => a
mempty