Alexis Hernandez
7 years ago
10 changed files with 72 additions and 27 deletions
@ -0,0 +1,11 @@ |
|||
package com.xsn.explorer.models |
|||
|
|||
import com.xsn.explorer.models.base.WrappedInt |
|||
import play.api.libs.json.{JsPath, Reads} |
|||
|
|||
case class Confirmations(int: Int) extends AnyVal with WrappedInt |
|||
|
|||
object Confirmations { |
|||
|
|||
implicit val reads: Reads[Confirmations] = JsPath.read[Int].map(Confirmations.apply) |
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.xsn.explorer.models |
|||
|
|||
import com.xsn.explorer.models.base.WrappedInt |
|||
import play.api.libs.json.{JsPath, Reads} |
|||
|
|||
case class Size(int: Int) extends AnyVal with WrappedInt |
|||
|
|||
object Size { |
|||
|
|||
implicit val reads: Reads[Size] = JsPath.read[Int].map(Size.apply) |
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.xsn.explorer.models.base |
|||
|
|||
import play.api.libs.json.{JsNumber, Writes} |
|||
|
|||
trait WrappedInt extends Any { |
|||
def int: Int |
|||
} |
|||
|
|||
object WrappedInt { |
|||
|
|||
implicit val writes: Writes[WrappedInt] = { |
|||
Writes[WrappedInt] { wrapped => JsNumber(wrapped.int) } |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.xsn.explorer.models.base |
|||
|
|||
import play.api.libs.json.{JsString, Writes} |
|||
|
|||
trait WrappedString extends Any { |
|||
def string: String |
|||
} |
|||
|
|||
object WrappedString { |
|||
|
|||
implicit val writes: Writes[WrappedString] = { |
|||
Writes[WrappedString] { wrapped => JsString(wrapped.string) } |
|||
} |
|||
} |
Loading…
Reference in new issue