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.
24 lines
673 B
24 lines
673 B
package com.xsn.explorer.models
|
|
|
|
import play.api.libs.functional.syntax._
|
|
import play.api.libs.json._
|
|
|
|
case class AddressBalance(balance: BigInt, received: BigInt)
|
|
|
|
object AddressBalance {
|
|
implicit val reads: Reads[AddressBalance] = {
|
|
val builder = (__ \ 'balance).read[BigDecimal] and (__ \ 'received).read[BigDecimal]
|
|
|
|
builder.apply { (balance, received) =>
|
|
AddressBalance(balance.toBigInt(), received.toBigInt())
|
|
}
|
|
}
|
|
|
|
implicit val writes: Writes[AddressBalance] = Writes { obj =>
|
|
val values = Map(
|
|
"balance" -> JsNumber(BigDecimal(obj.balance)),
|
|
"received" -> JsNumber(BigDecimal(obj.received)))
|
|
|
|
JsObject.apply(values)
|
|
}
|
|
}
|
|
|