From 9a1b203142a997ea302d204c5c33ca49690dc451 Mon Sep 17 00:00:00 2001 From: Scott Goodwin <33629936+scott-goodwin@users.noreply.github.com> Date: Mon, 24 Oct 2022 10:57:24 +0100 Subject: [PATCH] DL-8959 - adding the searchItem functionality --- app/v1/connectors/PenaltiesConnector.scala | 6 +++--- app/v1/controllers/FinancialDataController.scala | 4 ++-- .../requestParsers/FinancialDataRequestParser.scala | 2 +- app/v1/models/request/penalties/FinancialRawData.scala | 2 +- app/v1/models/request/penalties/FinancialRequest.scala | 2 +- conf/v1WithPenalties.routes | 2 +- test/v1/constants/FinancialDataConstants.scala | 8 ++++---- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/v1/connectors/PenaltiesConnector.scala b/app/v1/connectors/PenaltiesConnector.scala index 96e0587f..38ad6606 100644 --- a/app/v1/connectors/PenaltiesConnector.scala +++ b/app/v1/connectors/PenaltiesConnector.scala @@ -67,7 +67,7 @@ class PenaltiesConnector @Inject()(val http: HttpClient, val logDetails = s"request failed. ${e.getMessage}" logger.error(ConnectorError.log( - logContext = "[PenaltiesConnector][retrieveFinancialData]", + logContext = "[PenaltiesConnector][retrievePenaltiesData]", vrn = vrn, details = logDetails, )) @@ -89,8 +89,8 @@ class PenaltiesConnector @Inject()(val http: HttpClient, userRequest: UserRequest[_], correlationId: String): Future[Outcome[FinancialDataResponse]] = { val vrn = request.vrn.vrn - val url = appConfig.penaltiesBaseUrl + s"/penalties/penalty/financial-data/VRN/$vrn/VATC" - logger.debug(s"[PenaltiesConnector][retrieveFinancialData] url: $url") + val searchItem = request.searchItem + val url = appConfig.penaltiesBaseUrl + s"/penalties/penalty/financial-data/VRN/$vrn/VATC?searchItem=${searchItem}" def doGet(implicit hc: HeaderCarrier): Future[Outcome[FinancialDataResponse]] = { diff --git a/app/v1/controllers/FinancialDataController.scala b/app/v1/controllers/FinancialDataController.scala index ee1fd139..a023744d 100644 --- a/app/v1/controllers/FinancialDataController.scala +++ b/app/v1/controllers/FinancialDataController.scala @@ -50,7 +50,7 @@ class FinancialDataController @Inject()(val authService: EnrolmentsAuthService, ) - def retrieveFinancialData(vrn: String, searhItem:String): Action[AnyContent] = authorisedAction(vrn).async { implicit request => + def retrieveFinancialData(vrn: String, searchItem:String): Action[AnyContent] = authorisedAction(vrn).async { implicit request => implicit val correlationId: String = idGenerator.getUid @@ -60,7 +60,7 @@ class FinancialDataController @Inject()(val authService: EnrolmentsAuthService, val result: EitherT[Future, ErrorWrapper, Result] = { for { - parsedRequest <- EitherT.fromEither[Future](requestParser.parseRequest(FinancialRawData(vrn))) + parsedRequest <- EitherT.fromEither[Future](requestParser.parseRequest(FinancialRawData(vrn, searchItem))) serviceResponse <- EitherT(service.retrieveFinancialData(parsedRequest)) } yield { diff --git a/app/v1/controllers/requestParsers/FinancialDataRequestParser.scala b/app/v1/controllers/requestParsers/FinancialDataRequestParser.scala index 4bc71a3c..d3c24ce4 100644 --- a/app/v1/controllers/requestParsers/FinancialDataRequestParser.scala +++ b/app/v1/controllers/requestParsers/FinancialDataRequestParser.scala @@ -24,6 +24,6 @@ import v1.models.request.penalties.{FinancialRawData, FinancialRequest, Penaltie class FinancialDataRequestParser @Inject()(val validator: FinancialDataValidator) extends RequestParser[FinancialRawData, FinancialRequest] { protected def requestFor(data: FinancialRawData): FinancialRequest = { - FinancialRequest(Vrn(data.vrn)) + FinancialRequest(Vrn(data.vrn), data.searchItem) } } diff --git a/app/v1/models/request/penalties/FinancialRawData.scala b/app/v1/models/request/penalties/FinancialRawData.scala index 778a6260..26bed38e 100644 --- a/app/v1/models/request/penalties/FinancialRawData.scala +++ b/app/v1/models/request/penalties/FinancialRawData.scala @@ -18,4 +18,4 @@ package v1.models.request.penalties import v1.models.request.RawData -case class FinancialRawData(vrn: String) extends RawData +case class FinancialRawData(vrn: String, searchItem: String) extends RawData diff --git a/app/v1/models/request/penalties/FinancialRequest.scala b/app/v1/models/request/penalties/FinancialRequest.scala index bce241d3..20c634e2 100644 --- a/app/v1/models/request/penalties/FinancialRequest.scala +++ b/app/v1/models/request/penalties/FinancialRequest.scala @@ -19,4 +19,4 @@ package v1.models.request.penalties import v1.models.domain.Vrn import v1.models.request.RawData -case class FinancialRequest(vrn: Vrn) extends RawData \ No newline at end of file +case class FinancialRequest(vrn: Vrn, searchItem: String) extends RawData \ No newline at end of file diff --git a/conf/v1WithPenalties.routes b/conf/v1WithPenalties.routes index 1386aa8c..38c0705b 100644 --- a/conf/v1WithPenalties.routes +++ b/conf/v1WithPenalties.routes @@ -17,4 +17,4 @@ GET /:vrn/payments v1.controllers.PaymentsC GET /:vrn/penalties v1.controllers.PenaltiesController.retrievePenalties(vrn) # VAT Financial Details -GET /:vrn/financial-details/:searhItem v1.controllers.FinancialDataController.retrieveFinancialData(vrn, searhItem) \ No newline at end of file +GET /:vrn/financial-details/:searchItem v1.controllers.FinancialDataController.retrieveFinancialData(vrn, searchItem) \ No newline at end of file diff --git a/test/v1/constants/FinancialDataConstants.scala b/test/v1/constants/FinancialDataConstants.scala index 235368c5..a07e189b 100644 --- a/test/v1/constants/FinancialDataConstants.scala +++ b/test/v1/constants/FinancialDataConstants.scala @@ -36,14 +36,14 @@ object FinancialDataConstants { val vrn: String = "123456789" val searchItem = "XC00178236592" - val rawData: FinancialRawData = FinancialRawData(vrn) - val financialRequest: FinancialRequest = FinancialRequest(Vrn(vrn)) + val rawData: FinancialRawData = FinancialRawData(vrn, searchItem) + val financialRequest: FinancialRequest = FinancialRequest(Vrn(vrn), searchItem) val invalidVrn = "fakeVRN" - val invalidRawData: FinancialRawData = FinancialRawData(invalidVrn) + val invalidRawData: FinancialRawData = FinancialRawData(invalidVrn, searchItem) def financialDataUrl(vrn: String = vrn)(implicit appConfig: AppConfig): String = s"/penalties/penalty/financial-data/VRN/$vrn/VATC" - def financialDataUrlWithConfig(vrn: String = vrn)(implicit appConfig: AppConfig): String = appConfig.penaltiesBaseUrl + s"/penalties/penalty/financial-data/VRN/$vrn/VATC" + def financialDataUrlWithConfig(vrn: String = vrn)(implicit appConfig: AppConfig): String = appConfig.penaltiesBaseUrl + s"/penalties/penalty/financial-data/VRN/$vrn/VATC?searchItem=${searchItem}" val testDownstreamFinancialDetailsNoDocumentDetails: JsValue = {