Skip to content

Commit

Permalink
RAS-460: Removed commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
mahipal-padala committed Oct 3, 2017
1 parent ae721f8 commit c4e0893
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
12 changes: 7 additions & 5 deletions app/uk/gov/hmrc/rasapi/connectors/DesConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ trait DesConnector extends ServicesConfig {
val httpGet: HttpGet
val httpPost: HttpPost
val desBaseUrl: String

def getResidencyStatusUrl(nino: String): String

val edhUrl: String

def getResidencyStatus(nino: Nino)(implicit hc: HeaderCarrier): Future[HttpResponse] = {
Expand All @@ -48,21 +50,21 @@ trait DesConnector extends ServicesConfig {
residencyStatus.nextYearForecastResidencyStatus))(implicitly[Writes[EDHAudit]], implicitly[HttpReads[HttpResponse]], updateHeaderCarrier(hc))
}

// private val httpReads: HttpReads[HttpResponse] = new HttpReads[HttpResponse] {
// override def read(method: String, url: String, response: HttpResponse) = response
// }

private def updateHeaderCarrier(headerCarrier: HeaderCarrier) =
headerCarrier.copy(extraHeaders = Seq("Environment" -> AppContext.desUrlHeaderEnv),
authorization = Some(Authorization(s"Bearer ${AppContext.desAuthToken}")))
}

object DesConnector extends DesConnector{
object DesConnector extends DesConnector {
// $COVERAGE-OFF$Trivial and never going to be called by a test that uses it's own object implementation
override val httpGet: HttpGet = WSHttp
override val httpPost: HttpPost = WSHttp
override val desBaseUrl = baseUrl("des")
override def getResidencyStatusUrl(nino: String) = String.format(AppContext.residencyStatusUrl, nino) //"/ras-stubs/get-residency-status"

override def getResidencyStatusUrl(nino: String) = String.format(AppContext.residencyStatusUrl, nino)

//"/ras-stubs/get-residency-status"
override val edhUrl: String = desBaseUrl + AppContext.edhUrl
// $COVERAGE-ON$
}
15 changes: 6 additions & 9 deletions app/uk/gov/hmrc/rasapi/services/HttpResponseHandlerService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ trait HttpResponseHandlerService {
val desConnector: DesConnector
val auditService: AuditService

def handleResidencyStatusResponse(nino: Nino, userId: String)(implicit request: Request[AnyContent], hc: HeaderCarrier) : Future[Either[ResidencyStatus, String]] = {
def handleResidencyStatusResponse(nino: Nino, userId: String)(implicit request: Request[AnyContent], hc: HeaderCarrier): Future[Either[ResidencyStatus, String]] = {

desConnector.getResidencyStatus(nino).map { response =>
Try(response.json.validate[ResidencyStatusSuccess]) match {
case Success(JsSuccess(payload, _)) =>
val resStatus = transformResidencyStatusValues(ResidencyStatus(currentYearResidencyStatus = payload.currentYearResidencyStatus,
nextYearForecastResidencyStatus = payload.nextYearResidencyStatus))
desConnector.sendDataToEDH(userId, nino.nino, resStatus).map{ httpResponse =>
desConnector.sendDataToEDH(userId, nino.nino, resStatus).map { httpResponse =>
auditEDHResponse(userId = userId, nino = nino.nino, auditSuccess = true)
} recover {
case _ =>
Expand All @@ -66,19 +66,16 @@ trait HttpResponseHandlerService {
}

ResidencyStatus(transformResidencyStatusValue(residencyStatus.currentYearResidencyStatus),
transformResidencyStatusValue(residencyStatus.nextYearForecastResidencyStatus))
transformResidencyStatusValue(residencyStatus.nextYearForecastResidencyStatus))
}
//
// private def is2xx(statusCode: Int): Boolean = {
// statusCode >= 200 && statusCode < 300
// }


private def auditEDHResponse(userId: String, nino: String, auditSuccess: Boolean)
(implicit request: Request[AnyContent], hc: HeaderCarrier): Unit = {

val auditDataMap = Map("userId" -> userId,
"nino" -> nino,
"edhAuditSuccess" -> auditSuccess.toString)
"nino" -> nino,
"edhAuditSuccess" -> auditSuccess.toString)

auditService.audit(auditType = "ReliefAtSourceAudit",
path = request.path,
Expand Down

0 comments on commit c4e0893

Please sign in to comment.