Skip to content

Commit d31e8a8

Browse files
committed
Started documentation.
1 parent 774c7f0 commit d31e8a8

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.controllers.v1
22

3+
import io.swagger.v3.oas.annotations.Operation
4+
import io.swagger.v3.oas.annotations.media.Content
5+
import io.swagger.v3.oas.annotations.media.Schema
6+
import io.swagger.v3.oas.annotations.responses.ApiResponse
37
import org.springframework.beans.factory.annotation.Autowired
48
import org.springframework.web.bind.annotation.GetMapping
59
import org.springframework.web.bind.annotation.PathVariable
@@ -9,6 +13,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception.BadRequestExce
913
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception.EntityNotFoundException
1014
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception.InternalServerErrorException
1115
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Balances
16+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.DataResponse
1217
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
1318
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
1419
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetBalancesForPersonService
@@ -17,7 +22,21 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetBalancesForP
1722
@RequestMapping("/v1/prison/{prisonId}/prisoners/{hmppsId}/balances")
1823
class BalancesController(@Autowired val getBalancesForPersonService: GetBalancesForPersonService,) {
1924
@GetMapping()
20-
fun getBalancesForPerson(@PathVariable hmppsId: String, @PathVariable prisonId: String): Response<Balances?> {
25+
@Operation(
26+
summary = "Returns a all accounts for a prisoner that they have at a prison.",
27+
description = "<b>Applicable filters</b>: <ul><li>prisons</li></ul>",
28+
responses = [
29+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found a prisoner's accounts."),
30+
ApiResponse(
31+
responseCode = "400",
32+
description = "The HMPPS ID provided has an invalid format or the prisoner does hot have accounts at the specified prison.",
33+
content = [Content(schema = Schema(ref = "#/components/schemas/BadRequest"))],
34+
),
35+
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
36+
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
37+
],
38+
)
39+
fun getBalancesForPerson(@PathVariable hmppsId: String, @PathVariable prisonId: String): DataResponse<Balances?> {
2140
val response = getBalancesForPersonService.execute(prisonId, hmppsId)
2241

2342
if (response.hasError(UpstreamApiError.Type.ENTITY_NOT_FOUND)) {
@@ -31,6 +50,6 @@ class BalancesController(@Autowired val getBalancesForPersonService: GetBalances
3150
if (response.hasError(UpstreamApiError.Type.INTERNAL_SERVER_ERROR)) {
3251
throw InternalServerErrorException("Error occurred while trying to get accounts for person with id: $hmppsId")
3352
}
34-
return response
53+
return DataResponse(response.data)
3554
}
3655
}

0 commit comments

Comments
 (0)