|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.xsn.explorer.models |
|
|
|
|
|
|
|
import play.api.libs.json._ |
|
|
|
|
|
|
|
case class Balance( |
|
|
|
address: Address, |
|
|
|
received: BigDecimal = BigDecimal(0), |
|
|
@ -7,3 +9,15 @@ case class Balance( |
|
|
|
|
|
|
|
def available: BigDecimal = received - spent |
|
|
|
} |
|
|
|
|
|
|
|
object Balance { |
|
|
|
implicit val writes: Writes[Balance] = Writes { obj => |
|
|
|
val values = Map( |
|
|
|
"address" -> JsString(obj.address.string), |
|
|
|
"received" -> JsNumber(obj.received), |
|
|
|
"spent" -> JsNumber(obj.spent), |
|
|
|
"available" -> JsNumber(obj.available)) |
|
|
|
|
|
|
|
JsObject.apply(values) |
|
|
|
} |
|
|
|
} |
|
|
|