File tree 1 file changed +5
-9
lines changed
src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services
1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -13,21 +13,17 @@ class GetLicenceConditionService(
13
13
@Autowired val getPersonService : GetPersonService ,
14
14
) {
15
15
fun execute (hmppsId : String ): Response <PersonLicences > {
16
- val personResponse = getPersonService.execute(hmppsId = hmppsId )
16
+ val personResponse = getPersonService.execute(hmppsId)
17
17
val crn = personResponse.data?.identifiers?.deliusCrn
18
18
19
19
var licences: Response <List <Licence >> = Response (data = emptyList())
20
20
var personLicences = PersonLicences (hmppsId)
21
21
if (crn != null ) {
22
22
licences = createAndVaryLicenceGateway.getLicenceSummaries(id = crn)
23
- licences.data.forEach {
24
- val licenceId = it.id.toIntOrNull()
25
- if (licenceId != null ) {
26
- val conditions = createAndVaryLicenceGateway.getLicenceConditions(licenceId)
27
- it.conditions = conditions.data
28
- } else {
29
- it.conditions = emptyList()
30
- }
23
+ licences.data.forEach { summary ->
24
+ summary.conditions = summary.id.toIntOrNull()?.let { licenceId ->
25
+ createAndVaryLicenceGateway.getLicenceConditions(licenceId).data
26
+ } ? : emptyList()
31
27
}
32
28
personLicences = PersonLicences (hmppsId, licences.data.firstOrNull()?.offenderNumber, licences.data)
33
29
}
You can’t perform that action at this time.
0 commit comments