aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala
diff options
context:
space:
mode:
authortimgushue <tim@driver.xyz>2017-09-27 09:34:45 -0700
committertimgushue <tim@driver.xyz>2017-09-27 09:34:45 -0700
commite9d3e19f637614809aab39d9df2d1fcc6c78916e (patch)
tree29560b9b5bfb1b235c6429506f56fa9dab8d4510 /src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala
parent0ef0059e9b47430e52d6bad4ced5b1be7f3b1a0d (diff)
parentc24679f1ae7d7ccc4e6693535b0aa3ac0e1ca225 (diff)
downloadrest-query-e9d3e19f637614809aab39d9df2d1fcc6c78916e.tar.gz
rest-query-e9d3e19f637614809aab39d9df2d1fcc6c78916e.tar.bz2
rest-query-e9d3e19f637614809aab39d9df2d1fcc6c78916e.zip
Merge branch 'master' into add-slot-eligibility-arms
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala
index ebef225..3db8bfa 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/intervention/ApiInterventionType.scala
@@ -2,23 +2,25 @@ 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
+import xyz.driver.pdsuidomain.entities.InterventionType.DeliveryMethod
-final case class ApiInterventionType(id: Long, name: String) {
+final case class ApiInterventionType(id: Long, name: String, deliveryMethods: List[String]) {
- def toDomain = InterventionType(id = LongId[InterventionType](id), name = name)
+ def toDomain = InterventionType.typeFromString(name)
}
object ApiInterventionType {
implicit val format: Format[ApiInterventionType] = (
(JsPath \ "id").format[Long] and
- (JsPath \ "name").format[String]
+ (JsPath \ "name").format[String] and
+ (JsPath \ "deliveryMethods").format[List[String]]
)(ApiInterventionType.apply, unlift(ApiInterventionType.unapply))
def fromDomain(interventionType: InterventionType) = ApiInterventionType(
id = interventionType.id.id,
- name = interventionType.name
+ name = interventionType.name,
+ deliveryMethods = interventionType.deliveryMethods.map(DeliveryMethod.methodToString).toList
)
}