From 68537891ca8f1b06301bbe7b996e5eb4ed680e39 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Wed, 18 Oct 2017 14:15:45 +0700 Subject: Added REST API methods to HypothesisService --- .../pdsuidomain/services/HypothesisService.scala | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala index 52cd6c8..9dc8d33 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala @@ -2,12 +2,21 @@ package xyz.driver.pdsuidomain.services import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext import xyz.driver.pdsuicommon.db.Sorting +import xyz.driver.pdsuicommon.domain.UuidId import xyz.driver.pdsuicommon.error.DomainError import xyz.driver.pdsuidomain.entities.Hypothesis import scala.concurrent.Future object HypothesisService { + trait DefaultNotFoundError { + def userMessage: String = "Intervention not found" + } + + trait DefaultAccessDeniedError { + def userMessage: String = "Access denied" + } + sealed trait GetListReply object GetListReply { final case class EntityList(xs: Seq[Hypothesis], totalFound: Int) extends GetListReply @@ -16,6 +25,32 @@ object HypothesisService { def userMessage: String = "Access denied" } } + + sealed trait CreateReply + object CreateReply { + final case class Created(x: Hypothesis) extends CreateReply + + type Error = CreateReply with DomainError + + case object AuthorizationError + extends CreateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends CreateReply with DomainError + } + + sealed trait DeleteReply + object DeleteReply { + case object Deleted extends DeleteReply + + type Error = DeleteReply with DomainError + + case object NotFoundError extends DeleteReply with DefaultNotFoundError with DomainError.NotFoundError + + case object AuthorizationError + extends DeleteReply with DefaultAccessDeniedError with DomainError.AuthorizationError + + final case class CommonError(userMessage: String) extends DeleteReply with DomainError + } } trait HypothesisService { @@ -24,4 +59,8 @@ trait HypothesisService { def getAll(sorting: Option[Sorting] = None)( implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + + def create(draftHypothesis: Hypothesis)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] + + def delete(id: UuidId[Hypothesis])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] } -- cgit v1.2.3 From 997407855c2293264dd160e6841f342aeaccf02a Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Fri, 20 Oct 2017 10:22:28 +0700 Subject: Fixed typo in HypothesisService --- src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala index 9dc8d33..572edb6 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/HypothesisService.scala @@ -10,7 +10,7 @@ import scala.concurrent.Future object HypothesisService { trait DefaultNotFoundError { - def userMessage: String = "Intervention not found" + def userMessage: String = "Hypothesis not found" } trait DefaultAccessDeniedError { -- cgit v1.2.3