diff options
author | ktomskikh <ktomskih@datamonsters.co> | 2017-09-25 16:42:02 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-25 16:42:02 +0700 |
commit | 969ddd91fd5fd6ad2f177be408e598b64f2d615c (patch) | |
tree | 8219b5b5d912d562cdc5480059334f3922b517e9 /src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala | |
parent | 07602feb5da0914a09103e1f1775e718ab768445 (diff) | |
parent | 25ccda10b3b7f16f9fcee0b41c4abd035b3d1330 (diff) | |
download | rest-query-969ddd91fd5fd6ad2f177be408e598b64f2d615c.tar.gz rest-query-969ddd91fd5fd6ad2f177be408e598b64f2d615c.tar.bz2 rest-query-969ddd91fd5fd6ad2f177be408e598b64f2d615c.zip |
Merge pull request #28 from drivergroup/PDSUI-2259v0.3.17
PDSUI-2259 Added create and delete endpoint for intervention service
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala index e593c3b..025a48a 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestInterventionService.scala @@ -1,7 +1,6 @@ package xyz.driver.pdsuidomain.services.rest import scala.concurrent.{ExecutionContext, Future} - import akka.http.scaladsl.marshalling.Marshal import akka.http.scaladsl.model._ import akka.stream.Materializer @@ -61,4 +60,26 @@ class RestInterventionService(transport: ServiceTransport, baseUri: Uri)( } } + def create(draftIntervention: InterventionWithArms)( + implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] = { + for { + entity <- Marshal(ApiIntervention.fromDomain(draftIntervention)).to[RequestEntity] + request = HttpRequest(HttpMethods.POST, endpointUri(baseUri, "/v1/intervention")).withEntity(entity) + response <- transport.sendRequestGetResponse(requestContext)(request) + reply <- apiResponse[ApiIntervention](response) + } yield { + CreateReply.Created(reply.toDomain) + } + } + + def delete(id: LongId[Intervention])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] = { + val request = HttpRequest(HttpMethods.DELETE, endpointUri(baseUri, s"/v1/intervention/$id")) + for { + response <- transport.sendRequestGetResponse(requestContext)(request) + _ <- apiResponse[HttpEntity](response) + } yield { + DeleteReply.Deleted + } + } + } |