From 56187bec9276f51886a01a2752c663f2227d9fc3 Mon Sep 17 00:00:00 2001 From: vlad Date: Fri, 30 Jun 2017 23:06:43 -0700 Subject: Export entities JSON formats --- .../formats/json/queue/ApiQueueUploadItem.scala | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/queue/ApiQueueUploadItem.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/queue/ApiQueueUploadItem.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/queue/ApiQueueUploadItem.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/queue/ApiQueueUploadItem.scala new file mode 100644 index 0000000..cd76670 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/queue/ApiQueueUploadItem.scala @@ -0,0 +1,38 @@ +package xyz.driver.pdsuidomain.formats.json.queue + +import java.time.LocalDateTime + +import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue +import play.api.libs.json.{Format, Json} + +final case class ApiQueueUploadItem(kind: String, + tag: String, + created: LocalDateTime, + attempts: Int, + nextAttempt: LocalDateTime, + completed: Boolean) { + def toDomain = BridgeUploadQueue.Item( + kind = kind, + tag = tag, + created = created, + attempts = attempts, + nextAttempt = nextAttempt, + completed = true, + dependencyKind = None, + dependencyTag = None + ) +} + +object ApiQueueUploadItem { + + def fromDomain(domain: BridgeUploadQueue.Item) = ApiQueueUploadItem( + kind = domain.kind, + tag = domain.tag, + created = domain.created, + attempts = domain.attempts, + nextAttempt = domain.nextAttempt, + completed = domain.completed + ) + + implicit val format: Format[ApiQueueUploadItem] = Json.format[ApiQueueUploadItem] +} -- cgit v1.2.3