aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala
diff options
context:
space:
mode:
authorkseniya <ktomskih@datamonsters.co>2017-09-22 18:09:32 +0700
committerkseniya <ktomskih@datamonsters.co>2017-09-22 18:24:21 +0700
commit49cda2524a2537cb9330af488ca9c30e435f5849 (patch)
treeaa5ae32b5980171a8a08c78331366f03c550d619 /src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala
parentf1c217d2e6ff2e195e7374605878c7a347a074c7 (diff)
downloadrest-query-49cda2524a2537cb9330af488ca9c30e435f5849.tar.gz
rest-query-49cda2524a2537cb9330af488ca9c30e435f5849.tar.bz2
rest-query-49cda2524a2537cb9330af488ca9c30e435f5849.zip
Added create and delete endpoint to intervention service
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala
index 439e456..1e7c7f1 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/InterventionService.scala
@@ -61,6 +61,37 @@ object InterventionService {
final case class CommonError(userMessage: String) extends UpdateReply with DomainError
}
+ sealed trait CreateReply
+ object CreateReply {
+ final case class Created(x: InterventionWithArms) 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
+
+ implicit def toPhiString(reply: CreateReply): PhiString = reply match {
+ case Created(x) => phi"Created($x)"
+ case x: Error => DomainError.toPhiString(x)
+ }
+ }
+
+ 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 InterventionService {
@@ -76,4 +107,9 @@ trait InterventionService {
def update(origIntervention: InterventionWithArms, draftIntervention: InterventionWithArms)(
implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply]
+
+ def create(draftIntervention: InterventionWithArms)(
+ implicit requestContext: AuthenticatedRequestContext): Future[CreateReply]
+
+ def delete(id: LongId[Intervention])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply]
}