Skip to content

Commit

Permalink
Merge pull request #263 from hmrc/ITSASU-2824
Browse files Browse the repository at this point in the history
ITSASU-2824 - Remove the old business details connector and feature s…
  • Loading branch information
srikanthsunkara79 authored Jan 23, 2024
2 parents f092700 + d92b88e commit bfe5401
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 571 deletions.
22 changes: 4 additions & 18 deletions app/config/MicroserviceAppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import javax.inject.{Inject, Singleton}

trait AppConfig {
val configuration: Configuration
val authURL: String
val ggURL: String
val ggAdminURL: String
val ggAuthenticationURL: String

val timeToLiveSeconds: Int
val throttleTimeToLiveSeconds: Int
Expand All @@ -38,35 +34,31 @@ trait AppConfig {

val desEnvironment: String
val desToken: String
val paperlessPreferencesExpirySeconds: Int
val desAuthorisationToken: String
val desEnvironmentHeader: (String, String)

def getBusinessDetailsURL: String

val getBusinessDetailsAuthorisationToken: String
val getBusinessDetailsEnvironment: String

def statusDeterminationServiceURL: String

val statusDeterminationServiceAuthorisationToken: String
val statusDeterminationServiceEnvironment: String

def signUpServiceURL: String

val signUpServiceAuthorisationToken: String
val signUpServiceEnvironment: String
}



@Singleton
class MicroserviceAppConfig @Inject()(servicesConfig: ServicesConfig, val configuration: Configuration) extends AppConfig {

private def loadConfig(key: String) = servicesConfig.getString(key)

override lazy val authURL: String = servicesConfig.baseUrl("auth")
override lazy val ggAuthenticationURL: String = servicesConfig.baseUrl("gg-authentication")
override lazy val ggURL: String = servicesConfig.baseUrl("government-gateway")
override lazy val ggAdminURL: String = servicesConfig.baseUrl("gg-admin")

override lazy val getBusinessDetailsURL: String = servicesConfig.baseUrl("get-business-details")

private val getBusinessDetailsBase = "microservice.services.get-business-details"
Expand All @@ -77,7 +69,7 @@ class MicroserviceAppConfig @Inject()(servicesConfig: ServicesConfig, val config

private val statusDeterminationServiceBase = "microservice.services.status-determination-service"
override lazy val statusDeterminationServiceAuthorisationToken: String = s"Bearer ${loadConfig(s"$statusDeterminationServiceBase.authorization-token")}"
override lazy val statusDeterminationServiceEnvironment: String= loadConfig(s"$statusDeterminationServiceBase.environment")
override lazy val statusDeterminationServiceEnvironment: String = loadConfig(s"$statusDeterminationServiceBase.environment")


override lazy val signUpServiceURL: String = servicesConfig.baseUrl("signup-tax-year-service")
Expand All @@ -99,16 +91,10 @@ class MicroserviceAppConfig @Inject()(servicesConfig: ServicesConfig, val config

override lazy val desEnvironment: String = loadConfig(s"$desBase.environment")
override lazy val desToken: String = loadConfig(s"$desBase.authorization-token")
override val paperlessPreferencesExpirySeconds: Int = {
servicesConfig.getInt(s"paperless-preference.expiry-seconds")
}

lazy val mongoUri: String = loadConfig("mongodb.uri")

lazy val timeToLiveSeconds: Int = loadConfig("mongodb.timeToLiveSeconds").toInt
lazy val throttleTimeToLiveSeconds: Int = loadConfig("mongodb.throttleTimeToLiveSeconds").toInt

def businessSubscribeUrl(nino: String): String = s"$desURL/income-tax-self-assessment/nino/$nino/business"

def propertySubscribeUrl(nino: String): String = s"$desURL/income-tax-self-assessment/nino/$nino/properties"
}
9 changes: 1 addition & 8 deletions app/config/featureswitch/FeatureSwitch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ object FeatureSwitch {
val prefix = "feature-switch"

val switches: Set[FeatureSwitch] = Set(
StubDESFeature,
NewGetBusinessDetails
StubDESFeature
)

def apply(str: String): FeatureSwitch =
Expand All @@ -49,9 +48,3 @@ object StubDESFeature extends FeatureSwitch {
val displayName = s"Use stub for DES connection"
val name = s"$prefix.stub-des"
}

object NewGetBusinessDetails extends FeatureSwitch {
val displayName = s"Use the new get business details API"
val name = s"$prefix.new-get-business-details"
}

91 changes: 0 additions & 91 deletions app/connectors/OldBusinessDetailsConnector.scala

This file was deleted.

35 changes: 10 additions & 25 deletions app/services/SubscriptionStatusService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package services

import config.AppConfig
import config.featureswitch.{FeatureSwitching, NewGetBusinessDetails}
import connectors.{BusinessDetailsConnector, OldBusinessDetailsConnector}
import config.featureswitch.FeatureSwitching
import connectors.BusinessDetailsConnector
import models.ErrorModel
import models.frontend.FESuccessResponse
import play.api.Logging
Expand All @@ -31,7 +31,6 @@ import scala.concurrent.{ExecutionContext, Future}

@Singleton
class SubscriptionStatusService @Inject()(val appConfig: AppConfig,
oldBusinessDetailsConnector: OldBusinessDetailsConnector,
businessDetailsConnector: BusinessDetailsConnector)
extends Logging with FeatureSwitching {

Expand All @@ -43,29 +42,15 @@ class SubscriptionStatusService @Inject()(val appConfig: AppConfig,

def checkMtditsaSubscription(nino: String)
(implicit hc: HeaderCarrier, ec: ExecutionContext, request: Request[_]): Future[Either[ErrorModel, Option[FESuccessResponse]]] = {

if (isEnabled(NewGetBusinessDetails)) {
businessDetailsConnector.getBusinessDetails(nino) map {
case Right(response) =>
Right(Some(FESuccessResponse(Some(response.mtdId))))
case Left(error: ErrorModel) =>
if (error.status == NOT_FOUND) {
Right(None)
} else {
Left(error)
}
}
} else {
oldBusinessDetailsConnector.getBusinessDetails(nino).map {
// if the subscription is not found, convert it to OK with {}
case Left(error: ErrorModel) if error.status == NOT_FOUND =>
logger.debug(s"SubscriptionStatusService.checkMtditsaEnrolment - No mtditsa enrolment for nino=$nino")
businessDetailsConnector.getBusinessDetails(nino) map {
case Right(response) =>
Right(Some(FESuccessResponse(Some(response.mtdId))))
case Left(error: ErrorModel) =>
if (error.status == NOT_FOUND) {
Right(None)
case Right(x) =>
logger.debug(s"SubscriptionStatusService.checkMtditsaEnrolment - Client is already enrolled with mtditsa, ref=${x.mtdbsa}")
Right(Some(FESuccessResponse(Some(x.mtdbsa))))
case Left(x) => Left(x)
}
} else {
Left(error)
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ throttle {
}
}

paperless-preference.expiry-seconds = 3600

microservice {
services {

Expand Down
Loading

0 comments on commit bfe5401

Please sign in to comment.