blob: ebef22596afebf279d2724b646e97c68381083ba (
plain) (
tree)
|
|
package xyz.driver.pdsuidomain.formats.json.intervention
import play.api.libs.functional.syntax._
import play.api.libs.json.{Format, JsPath}
import xyz.driver.pdsuicommon.domain.LongId
import xyz.driver.pdsuidomain.entities.InterventionType
final case class ApiInterventionType(id: Long, name: String) {
def toDomain = InterventionType(id = LongId[InterventionType](id), name = name)
}
object ApiInterventionType {
implicit val format: Format[ApiInterventionType] = (
(JsPath \ "id").format[Long] and
(JsPath \ "name").format[String]
)(ApiInterventionType.apply, unlift(ApiInterventionType.unapply))
def fromDomain(interventionType: InterventionType) = ApiInterventionType(
id = interventionType.id.id,
name = interventionType.name
)
}
|