You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
711 B

package com.xsn.explorer.models
import play.api.libs.json._
case class StatisticsDetails(statistics: Statistics, masternodes: Option[Int])
object StatisticsDetails {
implicit val writes: Writes[StatisticsDetails] = Writes { obj =>
val values = Map(
"blocks" -> JsNumber(obj.statistics.blocks),
"transactions" -> JsNumber(obj.statistics.transactions),
"totalSupply" -> JsNumber(obj.statistics.totalSupply),
"circulatingSupply" -> JsNumber(obj.statistics.circulatingSupply))
val result = obj.masternodes
.map { count =>
values + ("masternodes" -> JsNumber(count))
}
.getOrElse {
values
}
JsObject.apply(result)
}
}