Skip to content

Commit 2eaa8ec

Browse files
The keys are distinct
1 parent 9fa3e08 commit 2eaa8ec

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

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

+11-18
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,17 @@ class GetPersonService(
2626
prisonerOffenderSearchGateway.getPrisonOffender(nomsNumber = it)
2727
}
2828

29-
return if (prisonResponse != null) {
30-
Response(
31-
data =
32-
mapOf(
33-
"prisonerOffenderSearch" to prisonResponse.data?.toPerson(),
34-
"probationOffenderSearch" to probationResponse.data,
35-
),
36-
errors = prisonResponse.errors + probationResponse.errors,
29+
val data =
30+
mapOf(
31+
"prisonerOffenderSearch" to prisonResponse?.data?.toPerson(),
32+
"probationOffenderSearch" to probationResponse.data,
3733
)
38-
} else {
39-
Response(
40-
data =
41-
mapOf(
42-
"prisonerOffenderSearch" to null,
43-
"probationOffenderSearch" to probationResponse.data,
44-
),
45-
errors = probationResponse.errors,
46-
)
47-
}
34+
35+
val errors = (prisonResponse?.errors ?: emptyList()) + probationResponse.errors
36+
37+
return Response(
38+
data = data,
39+
errors = errors,
40+
)
4841
}
4942
}

0 commit comments

Comments
 (0)