diff options
author | Jakob Odersky <jakob@odersky.com> | 2017-07-14 15:25:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-14 15:25:38 -0700 |
commit | dd9e22ac2e085505e2b6a1ca476fe1dcdc7e8618 (patch) | |
tree | da106c15b9402f3f6f9f19f92fe2a2258d5cf7d3 /src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHypothesisService.scala | |
parent | 3d902b5197db861c30325c159dc10cfb211ae209 (diff) | |
parent | d733294cb16fa83be014ce1efccbf364aa309d25 (diff) | |
download | rest-query-babfc221f301cce4ce08bced827d3d743cb8764a.tar.gz rest-query-babfc221f301cce4ce08bced827d3d743cb8764a.tar.bz2 rest-query-babfc221f301cce4ce08bced827d3d743cb8764a.zip |
Merge pull request #7 from drivergroup/restification-tcv0.2.0
Implement trial curation rest services
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHypothesisService.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHypothesisService.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHypothesisService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHypothesisService.scala new file mode 100644 index 0000000..37b28ae --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHypothesisService.scala @@ -0,0 +1,33 @@ +package xyz.driver.pdsuidomain.services.rest + +import scala.concurrent.{ExecutionContext, Future} + +import akka.http.scaladsl.model._ +import akka.stream.ActorMaterializer +import xyz.driver.core.rest._ +import xyz.driver.pdsuicommon.auth._ +import xyz.driver.pdsuicommon.db._ +import xyz.driver.pdsuidomain.formats.json.ListResponse +import xyz.driver.pdsuidomain.formats.json.hypothesis.ApiHypothesis +import xyz.driver.pdsuidomain.services.HypothesisService + +class RestHypothesisService(transport: ServiceTransport, baseUri: Uri)( + implicit protected val materializer: ActorMaterializer, + protected val exec: ExecutionContext) + extends HypothesisService with RestHelper { + + import xyz.driver.pdsuicommon.serialization.PlayJsonSupport._ + import xyz.driver.pdsuidomain.services.HypothesisService._ + + def getAll(sorting: Option[Sorting] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] = { + val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, "/v1/hypothesis", sortingQuery(sorting))) + for { + response <- transport.sendRequestGetResponse(requestContext)(request) + reply <- apiResponse[ListResponse[ApiHypothesis]](response) + } yield { + GetListReply.EntityList(reply.items.map(_.toDomain), reply.meta.itemsCount) + } + } + +} |