module TD.Data.StarTransactions
(StarTransactions(..)) 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.StarAmount as StarAmount
import qualified TD.Data.StarTransaction as StarTransaction
import qualified Data.Text as T
data StarTransactions
= StarTransactions
{ StarTransactions -> Maybe StarAmount
star_amount :: Maybe StarAmount.StarAmount
, StarTransactions -> Maybe [StarTransaction]
transactions :: Maybe [StarTransaction.StarTransaction]
, StarTransactions -> Maybe Text
next_offset :: Maybe T.Text
}
deriving (StarTransactions -> StarTransactions -> Bool
(StarTransactions -> StarTransactions -> Bool)
-> (StarTransactions -> StarTransactions -> Bool)
-> Eq StarTransactions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StarTransactions -> StarTransactions -> Bool
== :: StarTransactions -> StarTransactions -> Bool
$c/= :: StarTransactions -> StarTransactions -> Bool
/= :: StarTransactions -> StarTransactions -> Bool
Eq, Int -> StarTransactions -> ShowS
[StarTransactions] -> ShowS
StarTransactions -> String
(Int -> StarTransactions -> ShowS)
-> (StarTransactions -> String)
-> ([StarTransactions] -> ShowS)
-> Show StarTransactions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StarTransactions -> ShowS
showsPrec :: Int -> StarTransactions -> ShowS
$cshow :: StarTransactions -> String
show :: StarTransactions -> String
$cshowList :: [StarTransactions] -> ShowS
showList :: [StarTransactions] -> ShowS
Show)
instance I.ShortShow StarTransactions where
shortShow :: StarTransactions -> String
shortShow StarTransactions
{ star_amount :: StarTransactions -> Maybe StarAmount
star_amount = Maybe StarAmount
star_amount_
, transactions :: StarTransactions -> Maybe [StarTransaction]
transactions = Maybe [StarTransaction]
transactions_
, next_offset :: StarTransactions -> Maybe Text
next_offset = Maybe Text
next_offset_
}
= String
"StarTransactions"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"star_amount" String -> Maybe StarAmount -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StarAmount
star_amount_
, String
"transactions" String -> Maybe [StarTransaction] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [StarTransaction]
transactions_
, String
"next_offset" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
next_offset_
]
instance AT.FromJSON StarTransactions where
parseJSON :: Value -> Parser StarTransactions
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
"starTransactions" -> Value -> Parser StarTransactions
parseStarTransactions Value
v
String
_ -> Parser StarTransactions
forall a. Monoid a => a
mempty
where
parseStarTransactions :: A.Value -> AT.Parser StarTransactions
parseStarTransactions :: Value -> Parser StarTransactions
parseStarTransactions = String
-> (Object -> Parser StarTransactions)
-> Value
-> Parser StarTransactions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StarTransactions" ((Object -> Parser StarTransactions)
-> Value -> Parser StarTransactions)
-> (Object -> Parser StarTransactions)
-> Value
-> Parser StarTransactions
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe StarAmount
star_amount_ <- Object
o Object -> Key -> Parser (Maybe StarAmount)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_amount"
Maybe [StarTransaction]
transactions_ <- Object
o Object -> Key -> Parser (Maybe [StarTransaction])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"transactions"
Maybe Text
next_offset_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_offset"
StarTransactions -> Parser StarTransactions
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StarTransactions -> Parser StarTransactions)
-> StarTransactions -> Parser StarTransactions
forall a b. (a -> b) -> a -> b
$ StarTransactions
{ star_amount :: Maybe StarAmount
star_amount = Maybe StarAmount
star_amount_
, transactions :: Maybe [StarTransaction]
transactions = Maybe [StarTransaction]
transactions_
, next_offset :: Maybe Text
next_offset = Maybe Text
next_offset_
}
parseJSON Value
_ = Parser StarTransactions
forall a. Monoid a => a
mempty