module TD.Data.GramRevenueStatistics
(GramRevenueStatistics(..)) 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.StatisticalGraph as StatisticalGraph
import qualified TD.Data.GramRevenueStatus as GramRevenueStatus
data GramRevenueStatistics
= GramRevenueStatistics
{ GramRevenueStatistics -> Maybe StatisticalGraph
revenue_by_day_graph :: Maybe StatisticalGraph.StatisticalGraph
, GramRevenueStatistics -> Maybe GramRevenueStatus
status :: Maybe GramRevenueStatus.GramRevenueStatus
, GramRevenueStatistics -> Maybe Double
usd_rate :: Maybe Double
}
deriving (GramRevenueStatistics -> GramRevenueStatistics -> Bool
(GramRevenueStatistics -> GramRevenueStatistics -> Bool)
-> (GramRevenueStatistics -> GramRevenueStatistics -> Bool)
-> Eq GramRevenueStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GramRevenueStatistics -> GramRevenueStatistics -> Bool
== :: GramRevenueStatistics -> GramRevenueStatistics -> Bool
$c/= :: GramRevenueStatistics -> GramRevenueStatistics -> Bool
/= :: GramRevenueStatistics -> GramRevenueStatistics -> Bool
Eq, Int -> GramRevenueStatistics -> ShowS
[GramRevenueStatistics] -> ShowS
GramRevenueStatistics -> String
(Int -> GramRevenueStatistics -> ShowS)
-> (GramRevenueStatistics -> String)
-> ([GramRevenueStatistics] -> ShowS)
-> Show GramRevenueStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GramRevenueStatistics -> ShowS
showsPrec :: Int -> GramRevenueStatistics -> ShowS
$cshow :: GramRevenueStatistics -> String
show :: GramRevenueStatistics -> String
$cshowList :: [GramRevenueStatistics] -> ShowS
showList :: [GramRevenueStatistics] -> ShowS
Show)
instance I.ShortShow GramRevenueStatistics where
shortShow :: GramRevenueStatistics -> String
shortShow GramRevenueStatistics
{ revenue_by_day_graph :: GramRevenueStatistics -> Maybe StatisticalGraph
revenue_by_day_graph = Maybe StatisticalGraph
revenue_by_day_graph_
, status :: GramRevenueStatistics -> Maybe GramRevenueStatus
status = Maybe GramRevenueStatus
status_
, usd_rate :: GramRevenueStatistics -> Maybe Double
usd_rate = Maybe Double
usd_rate_
}
= String
"GramRevenueStatistics"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"revenue_by_day_graph" String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
revenue_by_day_graph_
, String
"status" String -> Maybe GramRevenueStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GramRevenueStatus
status_
, String
"usd_rate" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
usd_rate_
]
instance AT.FromJSON GramRevenueStatistics where
parseJSON :: Value -> Parser GramRevenueStatistics
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
"gramRevenueStatistics" -> Value -> Parser GramRevenueStatistics
parseGramRevenueStatistics Value
v
String
_ -> Parser GramRevenueStatistics
forall a. Monoid a => a
mempty
where
parseGramRevenueStatistics :: A.Value -> AT.Parser GramRevenueStatistics
parseGramRevenueStatistics :: Value -> Parser GramRevenueStatistics
parseGramRevenueStatistics = String
-> (Object -> Parser GramRevenueStatistics)
-> Value
-> Parser GramRevenueStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GramRevenueStatistics" ((Object -> Parser GramRevenueStatistics)
-> Value -> Parser GramRevenueStatistics)
-> (Object -> Parser GramRevenueStatistics)
-> Value
-> Parser GramRevenueStatistics
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe StatisticalGraph
revenue_by_day_graph_ <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"revenue_by_day_graph"
Maybe GramRevenueStatus
status_ <- Object
o Object -> Key -> Parser (Maybe GramRevenueStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"status"
Maybe Double
usd_rate_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"usd_rate"
GramRevenueStatistics -> Parser GramRevenueStatistics
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GramRevenueStatistics -> Parser GramRevenueStatistics)
-> GramRevenueStatistics -> Parser GramRevenueStatistics
forall a b. (a -> b) -> a -> b
$ GramRevenueStatistics
{ revenue_by_day_graph :: Maybe StatisticalGraph
revenue_by_day_graph = Maybe StatisticalGraph
revenue_by_day_graph_
, status :: Maybe GramRevenueStatus
status = Maybe GramRevenueStatus
status_
, usd_rate :: Maybe Double
usd_rate = Maybe Double
usd_rate_
}
parseJSON Value
_ = Parser GramRevenueStatistics
forall a. Monoid a => a
mempty