aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala
blob: 54d2cb7bceebf7b07bd2395a116b60833f396188 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package xyz.driver.pdsuidomain.formats.json.intervention

import play.api.libs.functional.syntax._
import play.api.libs.json.{Format, JsPath}
import xyz.driver.pdsuidomain.entities.InterventionType

final case class ApiInterventionType(id: Long, name: String)

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
  )
}