diff --git a/.scalafmt.conf b/.scalafmt.conf index f8473a7..11b74e3 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,5 @@ -version = 2.7.5 +version = 3.0.0 +runner.dialect = scala213 style = defaultWithAlign maxColumn = 120 @@ -43,4 +44,4 @@ rewrite { spaces { inImportCurlyBraces = false beforeContextBoundColon = Never -} \ No newline at end of file +} diff --git a/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala b/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala index fae0634..51adcb0 100644 --- a/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala +++ b/app/uk/gov/hmrc/currencyconversion/connectors/HODConnector.scala @@ -16,16 +16,17 @@ package uk.gov.hmrc.currencyconversion.connectors -import org.apache.pekko.pattern.CircuitBreaker import com.google.inject.Inject import com.google.inject.name.Named +import org.apache.pekko.pattern.CircuitBreaker import play.api.Configuration import play.api.http.Status.{OK, SERVICE_UNAVAILABLE} import play.api.http.{ContentTypes, HeaderNames} -import play.api.libs.json.{JsValue, Json} +import play.api.libs.json.Json import uk.gov.hmrc.currencyconversion.models.Service import uk.gov.hmrc.http.HttpReads.Implicits._ -import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, HttpResponse} +import uk.gov.hmrc.http.client.HttpClientV2 +import uk.gov.hmrc.http.{HeaderCarrier, HttpResponse, StringContextOps} import java.util.UUID import javax.inject.Singleton @@ -33,7 +34,7 @@ import scala.concurrent.{ExecutionContext, Future} @Singleton class HODConnector @Inject() ( - http: HttpClient, + http: HttpClientV2, config: Configuration, @Named("des") circuitBreaker: CircuitBreaker )(implicit ec: ExecutionContext) @@ -47,6 +48,9 @@ class HODConnector @Inject() ( private val CORRELATION_ID: String = "X-Correlation-ID" private val ENVIRONMENT: String = "Environment" + private val xrsFullUrl = s"$baseUrl$xrsEndPoint" + private val emptyJsonBody = Json.parse("""{}""") + def submit(): Future[HttpResponse] = { implicit val hc: HeaderCarrier = @@ -61,11 +65,15 @@ class HODConnector @Inject() ( ) def call(implicit hc: HeaderCarrier): Future[HttpResponse] = - http.POST[JsValue, HttpResponse](s"$baseUrl$xrsEndPoint", Json.parse("""{}""")).map { response => - (response.status: @unchecked) match { - case OK => HttpResponse(OK, response.body) + http + .post(url"$xrsFullUrl") + .withBody(emptyJsonBody) + .execute[HttpResponse] + .map { response => + response.status match { + case OK => HttpResponse(OK, response.body) + } } - } circuitBreaker .withCircuitBreaker(call) diff --git a/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala b/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala index 71d5916..8b5de7b 100644 --- a/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala +++ b/app/uk/gov/hmrc/currencyconversion/workers/XrsExchangeRateRequestWorker.scala @@ -27,7 +27,7 @@ import uk.gov.hmrc.currencyconversion.connectors.HODConnector import uk.gov.hmrc.currencyconversion.models.ExchangeRateData import uk.gov.hmrc.currencyconversion.repositories.ExchangeRateRepository import uk.gov.hmrc.currencyconversion.utils.MongoIdHelper.currentFileName -import uk.gov.hmrc.http.HttpReads.{is2xx, is4xx} +import uk.gov.hmrc.http.HttpErrorFunctions.{is2xx, is4xx} import uk.gov.hmrc.http.HttpResponse import java.time.LocalDate diff --git a/build.sbt b/build.sbt index 0ab7b6f..de0395c 100644 --- a/build.sbt +++ b/build.sbt @@ -23,4 +23,3 @@ lazy val microservice = Project(appName, file(".")) .settings(PlayKeys.playDefaultPort := 9016) addCommandAlias("scalafmtAll", "all scalafmtSbt scalafmt Test/scalafmt") -addCommandAlias("scalastyleAll", "all scalastyle Test/scalastyle ") diff --git a/conf/application.conf b/conf/application.conf index e29b1b5..950f9c6 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -16,7 +16,7 @@ include "backend.conf" appName=currency-conversion -play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule" +play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientV2Module" play.modules.enabled += "uk.gov.hmrc.mongo.play.PlayMongoModule" play.modules.enabled += "uk.gov.hmrc.currencyconversion.config.HmrcModule" diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index 48e6d8b..ad30121 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -2,7 +2,7 @@ import sbt.* object AppDependencies { - private lazy val bootstrapPlayVersion = "8.6.0" + private lazy val bootstrapPlayVersion = "9.0.0" private lazy val hmrcMongoVersion = "2.1.0" private lazy val compile: Seq[ModuleID] = Seq( diff --git a/project/plugins.sbt b/project/plugins.sbt index e775c5d..d94baa2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,10 +3,9 @@ resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefact Resolver.ivyStylePatterns ) -addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.22.0") -addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0") -addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.3") -addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0" exclude ("org.scala-lang.modules", "scala-xml_2.12")) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.22.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.3") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") diff --git a/run_all_tests.sh b/run_all_tests.sh index 2302662..eb36156 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -sbt clean compile scalafmtAll scalastyleAll coverage test dependencyUpdates coverageOff coverageReport +sbt clean compile scalafmtAll coverage test dependencyUpdates coverageOff coverageReport diff --git a/scalastyle-config.xml b/scalastyle-config.xml deleted file mode 100644 index 3827d10..0000000 --- a/scalastyle-config.xml +++ /dev/null @@ -1,117 +0,0 @@ - - Scalastyle standard configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -