Skip to content

Commit 5cb45c8

Browse files
API method to return the Review schedule
1 parent 524cdec commit 5cb45c8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/PLPController.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping
1414
import org.springframework.web.bind.annotation.RestController
1515
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception.EntityNotFoundException
1616
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.DataResponse
17+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.InductionSchedule
1718
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ReviewSchedule
1819
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
1920
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetInductionScheduleForPersonService
@@ -39,7 +40,7 @@ class PLPController(
3940
)
4041
fun getInductionSchedule(
4142
@Parameter(description = "A HMPPS id", example = "A123123") @PathVariable hmppsId: String,
42-
): DataResponse<ReviewSchedule> {
43+
): DataResponse<InductionSchedule> {
4344
val response = getInductionScheduleForPersonService.execute(hmppsId)
4445

4546
if (response.hasError(UpstreamApiError.Type.ENTITY_NOT_FOUND)) {

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/PLPGateway.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.springframework.http.HttpMethod
66
import org.springframework.stereotype.Component
77
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.WebClientWrapper
88
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.WebClientWrapper.WebClientWrapperResponse
9+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.InductionSchedule
910
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
1011
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ReviewSchedule
1112
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
@@ -19,9 +20,9 @@ class PLPGateway(
1920
@Autowired
2021
lateinit var hmppsAuthGateway: HmppsAuthGateway
2122

22-
fun getInductionSchedule(prisonerNumber: String): Response<ReviewSchedule> {
23+
fun getInductionSchedule(prisonerNumber: String): Response<InductionSchedule> {
2324
val result =
24-
webClient.request<ReviewSchedule>(
25+
webClient.request<InductionSchedule>(
2526
HttpMethod.GET,
2627
"/inductions/$prisonerNumber/induction-schedule",
2728
authenticationHeader(),
@@ -36,7 +37,7 @@ class PLPGateway(
3637

3738
is WebClientWrapperResponse.Error -> {
3839
Response(
39-
data = ReviewSchedule(),
40+
data = InductionSchedule(),
4041
errors = result.errors,
4142
)
4243
}

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetInductionScheduleForPersonService.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.services
33
import org.springframework.beans.factory.annotation.Autowired
44
import org.springframework.stereotype.Service
55
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.PLPGateway
6+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.InductionSchedule
67
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
7-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ReviewSchedule
88

99
@Service
1010
class GetInductionScheduleForPersonService(
1111
@Autowired val plpGateway: PLPGateway,
1212
@Autowired val getPersonService: GetPersonService,
1313
) {
14-
fun execute(hmppsId: String): Response<ReviewSchedule> {
14+
fun execute(hmppsId: String): Response<InductionSchedule> {
1515
val response = getPersonService.getNomisNumber(hmppsId = hmppsId)
1616

1717
response.data?.nomisNumber?.let {
1818
return plpGateway.getInductionSchedule(it)
1919
}
20-
return Response(ReviewSchedule(), response.errors)
20+
return Response(InductionSchedule(), response.errors)
2121
}
2222
}

0 commit comments

Comments
 (0)