blob: 9c0c21609d97393b6b13f05a9561c0e6f344d219 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package xyz.driver.pdsuidomain.formats.json.document
import play.api.libs.functional.syntax._
import play.api.libs.json.{Format, JsPath}
import xyz.driver.pdsuidomain.entities.ProviderType
final case class ApiProviderType(id: Long, name: String) {
def toDomain: ProviderType =
ProviderType
.fromString(name)
.getOrElse(throw new IllegalArgumentException(s"Unknown provider type name $name"))
}
object ApiProviderType {
implicit val format: Format[ApiProviderType] = (
(JsPath \ "id").format[Long] and
(JsPath \ "name").format[String]
)(ApiProviderType.apply, unlift(ApiProviderType.unapply))
def fromDomain(providerType: ProviderType) = ApiProviderType(
id = providerType.id.id,
name = providerType.name
)
}
|