Skip to content

Commit

Permalink
DL-8959 - adding the searchItem functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-goodwin committed Oct 24, 2022
1 parent 07bcd79 commit 9a1b203
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/v1/connectors/PenaltiesConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
))
Expand All @@ -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]] = {
Expand Down
4 changes: 2 additions & 2 deletions app/v1/controllers/FinancialDataController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion app/v1/models/request/penalties/FinancialRawData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/v1/models/request/penalties/FinancialRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
case class FinancialRequest(vrn: Vrn, searchItem: String) extends RawData
2 changes: 1 addition & 1 deletion conf/v1WithPenalties.routes
Original file line number Diff line number Diff line change
Expand Up @@ -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)
GET /:vrn/financial-details/:searchItem v1.controllers.FinancialDataController.retrieveFinancialData(vrn, searchItem)
8 changes: 4 additions & 4 deletions test/v1/constants/FinancialDataConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 9a1b203

Please sign in to comment.