From 5f1d0f32924d1e70ff6188fbabf81e6672a99002 Mon Sep 17 00:00:00 2001 From: Moritz Lintterer Date: Wed, 25 Oct 2023 08:51:32 +0200 Subject: [PATCH 1/2] fix: undo removing second apply method --- .../smithy4play/client/GenericAPIClient.scala | 25 +++++++++++-------- smithy4playTest/test/TestControllerTest.scala | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala b/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala index ec8dfe25..505ab778 100644 --- a/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala +++ b/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala @@ -49,26 +49,31 @@ object GenericAPIClient { def withClientAndHeaders( client: RequestClient, - additionalHeaders: Option[Map[String, Seq[String]]] - )(implicit ec: ExecutionContext): Alg[Kind1[ClientResponse]#toKind5] = apply(service, client, additionalHeaders) + additionalHeaders: Option[Map[String, Seq[String]]], + additionalSuccessCodes: List[Int] = List.empty + )(implicit ec: ExecutionContext): Alg[Kind1[ClientResponse]#toKind5] = + apply(service, additionalHeaders, additionalSuccessCodes, client) def withClient( - client: RequestClient - )(implicit ec: ExecutionContext): Alg[Kind1[ClientResponse]#toKind5] = apply(service, client) - - def toGenericClient( client: RequestClient, - additionalHeaders: Option[Map[String, Seq[String]]] = None, additionalSuccessCodes: List[Int] = List.empty - )(implicit ec: ExecutionContext): Alg[Kind1[ClientResponse]#toKind5] = - apply(service, client, additionalHeaders, additionalSuccessCodes) + )(implicit ec: ExecutionContext): Alg[Kind1[RunnableClientRequest]#toKind5] = + apply(service, client, additionalSuccessCodes) + } def apply[Alg[_[_, _, _, _, _]]]( serviceI: Service[Alg], client: RequestClient, - additionalHeaders: Option[Map[String, Seq[String]]] = None, additionalSuccessCodes: List[Int] = List.empty + )(implicit ec: ExecutionContext): Alg[Kind1[RunnableClientRequest]#toKind5] = + new GenericAPIClient(serviceI, client, additionalSuccessCodes).transformer() + + def apply[Alg[_[_, _, _, _, _]]]( + serviceI: Service[Alg], + additionalHeaders: Option[Map[String, Seq[String]]] = None, + additionalSuccessCodes: List[Int], + client: RequestClient )(implicit ec: ExecutionContext): Alg[Kind1[ClientResponse]#toKind5] = new GenericAPIClient(serviceI, client, additionalSuccessCodes).transformer(additionalHeaders) diff --git a/smithy4playTest/test/TestControllerTest.scala b/smithy4playTest/test/TestControllerTest.scala index 1876ec17..bd857297 100644 --- a/smithy4playTest/test/TestControllerTest.scala +++ b/smithy4playTest/test/TestControllerTest.scala @@ -53,7 +53,7 @@ class TestControllerTest extends PlaySpec with BaseOneAppPerSuite with FakeAppli } } - val genericClient = TestControllerServiceGen.toGenericClient(FakeRequestClient, None, List(269)) + val genericClient = TestControllerServiceGen.withClientAndHeaders(FakeRequestClient, None, List(269)) override def fakeApplication(): Application = new GuiceApplicationBuilder().build() From d79a849aef849abcd4a0f2bc474ebe5e3594e79f Mon Sep 17 00:00:00 2001 From: Moritz Lintterer Date: Wed, 25 Oct 2023 09:30:15 +0200 Subject: [PATCH 2/2] fix: compile error --- .../de/innfactory/smithy4play/client/GenericAPIClient.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala b/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala index 505ab778..783d76ce 100644 --- a/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala +++ b/smithy4play/src/main/scala/de/innfactory/smithy4play/client/GenericAPIClient.scala @@ -65,13 +65,13 @@ object GenericAPIClient { def apply[Alg[_[_, _, _, _, _]]]( serviceI: Service[Alg], client: RequestClient, - additionalSuccessCodes: List[Int] = List.empty + additionalSuccessCodes: List[Int] )(implicit ec: ExecutionContext): Alg[Kind1[RunnableClientRequest]#toKind5] = new GenericAPIClient(serviceI, client, additionalSuccessCodes).transformer() def apply[Alg[_[_, _, _, _, _]]]( serviceI: Service[Alg], - additionalHeaders: Option[Map[String, Seq[String]]] = None, + additionalHeaders: Option[Map[String, Seq[String]]], additionalSuccessCodes: List[Int], client: RequestClient )(implicit ec: ExecutionContext): Alg[Kind1[ClientResponse]#toKind5] =