Skip to content

Commit

Permalink
Merge pull request #266 from hmrc/ITSASU-2927
Browse files Browse the repository at this point in the history
ITSASU-2927 - Update mtdItsaSubscription audit to only produce on a s…
  • Loading branch information
srikanthsunkara79 authored Apr 25, 2024
2 parents 6c160f4 + b64cd34 commit 6bcbf3d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
14 changes: 10 additions & 4 deletions app/connectors/CreateIncomeSourcesConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class CreateIncomeSourcesConnector @Inject()(http: HttpClient,
appConfig: AppConfig,
auditService: AuditService)(implicit ec: ExecutionContext) {

def businessIncomeUrl(mtdbsaRef: String): String = s"${appConfig.desURL}/income-tax/income-sources/mtdbsa/$mtdbsaRef/ITSA/business"
private def businessIncomeUrl(mtdbsaRef: String): String = {
s"${appConfig.desURL}/income-tax/income-sources/mtdbsa/$mtdbsaRef/ITSA/business"
}

def createBusinessIncomeSources(agentReferenceNumber: Option[String],
mtdbsaRef: String,
createIncomeSources: CreateIncomeSourcesModel)
(implicit hc: HeaderCarrier, request: Request[_]): Future[PostIncomeSourceResponse] = {

auditService.extendedAudit(CompletedSignUpAudit(agentReferenceNumber, createIncomeSources, appConfig.desAuthorisationToken))

val headerCarrier: HeaderCarrier = hc
.copy(authorization = Some(Authorization(appConfig.desAuthorisationToken)))
.withExtraHeaders(appConfig.desEnvironmentHeader)
Expand All @@ -56,7 +56,13 @@ class CreateIncomeSourcesConnector @Inject()(http: HttpClient,
implicitly[HttpReads[PostIncomeSourceResponse]],
headerCarrier,
implicitly
)
) map {
case Left(error) =>
Left(error)
case Right(value) =>
auditService.extendedAudit(CompletedSignUpAudit(agentReferenceNumber, createIncomeSources, appConfig.desAuthorisationToken))
Right(value)
}

}

Expand Down
5 changes: 0 additions & 5 deletions app/repositories/SessionDataRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@
package repositories

import com.mongodb.client.model.{FindOneAndUpdateOptions, IndexOptions}
import com.mongodb.client.result.DeleteResult
import config.AppConfig
import org.bson.Document
import org.bson.conversions.Bson
import org.mongodb.scala.model.IndexModel
import org.mongodb.scala.result.InsertOneResult
import play.api.libs.json.Json.JsValueWrapper
import play.api.libs.json._
import uk.gov.hmrc.http.InternalServerException
import uk.gov.hmrc.mongo.MongoComponent
import uk.gov.hmrc.mongo.play.json.PlayMongoRepository
import utils.JsonUtils.JsObjectUtil

import java.time.Instant
import java.util.UUID
import java.util.concurrent.TimeUnit
import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}
Expand Down
13 changes: 6 additions & 7 deletions app/services/SessionDataService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,26 @@ import repositories.SessionDataRepository
import uk.gov.hmrc.http.{HeaderCarrier, InternalServerException}

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.Future

@Singleton
class SessionDataService @Inject()(sessionDataRepository: SessionDataRepository, val appConfig: AppConfig)
(implicit ec: ExecutionContext) extends FeatureSwitching {
class SessionDataService @Inject()(sessionDataRepository: SessionDataRepository, val appConfig: AppConfig) extends FeatureSwitching {


def getAllSessionData(implicit hc:HeaderCarrier): Future[Option[JsValue]] =
def getAllSessionData(implicit hc: HeaderCarrier): Future[Option[JsValue]] =
sessionDataRepository.getSessionData(sessionId = sessionIdFromHC)

def getSessionData(dataId: String)(implicit hc:HeaderCarrier): Future[Option[JsValue]] =
def getSessionData(dataId: String)(implicit hc: HeaderCarrier): Future[Option[JsValue]] =
sessionDataRepository.getDataFromSession(sessionId = sessionIdFromHC, dataId = dataId)

def insertSessionData(dataId: String, data: JsValue)(implicit hc:HeaderCarrier): Future[Option[JsValue]] =
def insertSessionData(dataId: String, data: JsValue)(implicit hc: HeaderCarrier): Future[Option[JsValue]] =
sessionDataRepository.insertDataWithSession(
sessionId = sessionIdFromHC,
dataId = dataId,
data = data
)

def deleteSessionData(dataId: String)(implicit hc:HeaderCarrier): Future[Option[JsValue]] =
def deleteSessionData(dataId: String)(implicit hc: HeaderCarrier): Future[Option[JsValue]] =
sessionDataRepository.deleteDataWithSession(
sessionId = sessionIdFromHC,
dataId = dataId
Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
resolvers += "HMRC-open-artefacts-maven" at "https://open.artefacts.tax.service.gov.uk/maven2"
resolvers += Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.21.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.4.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0")

addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.0")

Expand Down
3 changes: 0 additions & 3 deletions test/services/SessionDataServiceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package services

import com.mongodb.client.result.DeleteResult
import common.CommonSpec
import config.MicroserviceAppConfig
import config.featureswitch.FeatureSwitching
Expand All @@ -28,11 +27,9 @@ import play.api.Configuration
import play.api.libs.json.{JsObject, Json}
import play.api.test.Helpers.{await, defaultAwaitTimeout}
import repositories.SessionDataRepository
import services.SubscriptionDataService.{Created, Existence, Existing}
import uk.gov.hmrc.http.{HeaderCarrier, InternalServerException, SessionId}
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class SessionDataServiceSpec extends CommonSpec with MockitoSugar with FeatureSwitching with BeforeAndAfterEach {
Expand Down

0 comments on commit 6bcbf3d

Please sign in to comment.