Skip to content

Commit

Permalink
refactoring after upgrading server dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fupelaqu committed Jul 28, 2023
1 parent ea9fd7f commit 23ca8f0
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ThisBuild / organization := "app.softnetwork"

name := "payment"

ThisBuild / version := "0.4.1"
ThisBuild / version := "0.4.2"

ThisBuild / scalaVersion := "2.12.15"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package app.softnetwork.payment.launch

import akka.actor.typed.ActorSystem
import akka.http.scaladsl.server.Route
import app.softnetwork.api.server.ApiRoutes
import app.softnetwork.api.server.{ApiRoute, ApiRoutes}
import app.softnetwork.payment.serialization.paymentFormats
import app.softnetwork.payment.service.GenericPaymentService
import app.softnetwork.persistence.schema.SchemaProvider
Expand All @@ -17,6 +16,10 @@ trait PaymentRoutes extends ApiRoutes with PaymentGuardian { _: SchemaProvider =

def paymentService: ActorSystem[_] => GenericPaymentService

override def apiRoutes(system: ActorSystem[_]): Route = paymentService(system).route
override def apiRoutes: ActorSystem[_] => List[ApiRoute] =
system =>
List(
paymentService(system)
)

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package app.softnetwork.payment.service

import akka.http.scaladsl.server.Route
import app.softnetwork.payment.handlers.GenericPaymentHandler
import app.softnetwork.payment.message.PaymentMessages._
import app.softnetwork.payment.model._
Expand Down Expand Up @@ -57,7 +56,6 @@ trait GenericPaymentEndpoints
hooks
)

lazy val route: Route = apiRoute
}

case class UploadDocument(pages: Part[Array[Byte]]) { //TODO pages may include multiple parts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ trait GenericPaymentService
with DefaultComplete
with Json4sSupport
with StrictLogging
with BasicPaymentService { _: GenericPaymentHandler =>
with BasicPaymentService
with ApiRoute { _: GenericPaymentHandler =>

implicit def serialization: Serialization.type = jackson.Serialization

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.softnetwork.payment.api

import akka.actor.typed.ActorSystem
import app.softnetwork.api.server.ApiEndpoint
import app.softnetwork.session.service.SessionEndpoints
import com.softwaremill.session.{
Expand All @@ -15,7 +16,7 @@ import sttp.tapir._
import sttp.tapir.model.UsernamePassword
import sttp.tapir.server.{PartialServerEndpointWithSecurityOutput, ServerEndpoint}

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}
import scala.language.implicitConversions

trait BasicServiceEndpoint extends ApiEndpoint with TapirEndpoints {
Expand Down Expand Up @@ -63,8 +64,9 @@ trait BasicServiceEndpoint extends ApiEndpoint with TapirEndpoints {
}

object BasicServiceEndpoint {
def apply(_sessionEndpoints: SessionEndpoints): BasicServiceEndpoint =
def apply(_system: ActorSystem[_], _sessionEndpoints: SessionEndpoints): BasicServiceEndpoint =
new BasicServiceEndpoint {
override def sessionEndpoints: SessionEndpoints = _sessionEndpoints
override implicit def ec: ExecutionContext = _system.executionContext
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package app.softnetwork.payment.api

import akka.actor.typed.ActorSystem
import akka.http.scaladsl.server.Route
import app.softnetwork.api.server.ApiRoute
import app.softnetwork.persistence.schema.SchemaProvider
import app.softnetwork.scheduler.launch.SchedulerRoutes

trait MangoPayWithSchedulerRoutes extends SchedulerRoutes with MangoPayRoutes { _: SchemaProvider =>
override def apiRoutes(system: ActorSystem[_]): Route =
super.apiRoutes(system) ~ schedulerService(system).route
override def apiRoutes: ActorSystem[_] => List[ApiRoute] =
system => super.apiRoutes(system) :+ schedulerService(system)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package app.softnetwork.sbt.build

object Versions {

val genericPersistence = "0.3.4"
val genericPersistence = "0.3.5"

val scheduler = "0.3.4"
val scheduler = "0.3.5"

val scalatest = "3.1.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import app.softnetwork.api.server.ApiEndpoint
import app.softnetwork.payment.launch.PaymentEndpoints
import app.softnetwork.payment.service.{GenericPaymentEndpoints, MockPaymentEndpoints}
import app.softnetwork.persistence.schema.SchemaProvider
import app.softnetwork.session.scalatest.SessionEndpointsRoute
import app.softnetwork.session.scalatest.SessionEndpointsRoutes
import com.softwaremill.session.CsrfCheck

trait PaymentEndpointsTestKit extends PaymentEndpoints { _: SchemaProvider =>
trait PaymentEndpointsTestKit extends PaymentEndpoints with SessionEndpointsRoutes {
_: SchemaProvider with CsrfCheck =>

override def paymentEndpoints: ActorSystem[_] => GenericPaymentEndpoints = system =>
MockPaymentEndpoints(system, sessionEndpoints(system))

override def endpoints: ActorSystem[_] => List[ApiEndpoint] =
system =>
List(
SessionEndpointsRoute(system, sessionEndpoints(system)),
sessionServiceEndpoints(system),
paymentEndpoints(system)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package app.softnetwork.payment.scalatest

import akka.actor.typed.ActorSystem
import akka.http.scaladsl.server.Route
import app.softnetwork.api.server.ApiRoute
import app.softnetwork.payment.launch.PaymentRoutes
import app.softnetwork.payment.service.{GenericPaymentService, MockPaymentService}
import app.softnetwork.persistence.schema.SchemaProvider
import app.softnetwork.session.scalatest.SessionServiceRoute
import app.softnetwork.session.scalatest.SessionServiceRoutes

trait PaymentRoutesTestKit extends PaymentRoutes { _: SchemaProvider =>
trait PaymentRoutesTestKit extends PaymentRoutes with SessionServiceRoutes { _: SchemaProvider =>

override def paymentService: ActorSystem[_] => GenericPaymentService = system =>
MockPaymentService(system, sessionService(system))

override def apiRoutes(system: ActorSystem[_]): Route =
paymentService(system).route ~
SessionServiceRoute(sessionService(system)).route
override def apiRoutes: ActorSystem[_] => List[ApiRoute] =
system =>
List(
paymentService(system),
sessionServiceRoute(system)
)

}

0 comments on commit 23ca8f0

Please sign in to comment.