|
| 1 | +package uk.gov.justice.digital.hmpps.hmppsintegrationapi.controllers.v1 |
| 2 | + |
| 3 | +import ReferenceData |
| 4 | +import io.swagger.v3.oas.annotations.Hidden |
| 5 | +import io.swagger.v3.oas.annotations.Operation |
| 6 | +import io.swagger.v3.oas.annotations.media.Content |
| 7 | +import io.swagger.v3.oas.annotations.media.ExampleObject |
| 8 | +import io.swagger.v3.oas.annotations.media.Schema |
| 9 | +import io.swagger.v3.oas.annotations.responses.ApiResponse |
| 10 | +import org.springframework.boot.context.properties.EnableConfigurationProperties |
| 11 | +import org.springframework.web.bind.annotation.GetMapping |
| 12 | +import org.springframework.web.bind.annotation.RequestMapping |
| 13 | +import org.springframework.web.bind.annotation.RestController |
| 14 | +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.config.AuthorisationConfig |
| 15 | +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response |
| 16 | +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.ReferenceDataService |
| 17 | + |
| 18 | +@Hidden |
| 19 | +@RestController |
| 20 | +@EnableConfigurationProperties(AuthorisationConfig::class) |
| 21 | +@RequestMapping("/v1/reference-data") |
| 22 | +class ReferenceDataController( |
| 23 | + var referenceDataService: ReferenceDataService, |
| 24 | +) { |
| 25 | + @GetMapping |
| 26 | + @Operation( |
| 27 | + summary = """ |
| 28 | + Returns probation and prison reference data. |
| 29 | + > Prison Reference Data Types: PHONE_TYPE, ALERT_TYPE, ETHNICITY, GENDER |
| 30 | + > Probation Reference Data Types: PHONE_TYPE, REGISTER_TYPE, ETHNICITY, GENDER |
| 31 | + """, |
| 32 | + responses = [ |
| 33 | + ApiResponse( |
| 34 | + responseCode = "200", |
| 35 | + description = "Successfully returned prison and probation reference data.", |
| 36 | + content = [ |
| 37 | + Content( |
| 38 | + schema = Schema(implementation = Response::class), |
| 39 | + examples = [ |
| 40 | + ExampleObject( |
| 41 | + """{ |
| 42 | + "data": { |
| 43 | + "prisonReferenceData": { |
| 44 | + "PHONE_TYPE": [ |
| 45 | + { |
| 46 | + "code": "a", |
| 47 | + "description": "desc_a" |
| 48 | + }, |
| 49 | + { |
| 50 | + "code": "b", |
| 51 | + "description": "desc_b" |
| 52 | + }, |
| 53 | + { |
| 54 | + "code": "c", |
| 55 | + "description": "desc_c" |
| 56 | + } |
| 57 | + ], |
| 58 | + "ALERT_TYPE": [ |
| 59 | + { |
| 60 | + "code": "a", |
| 61 | + "description": "desc_a" |
| 62 | + }, |
| 63 | + { |
| 64 | + "code": "b", |
| 65 | + "description": "desc_b" |
| 66 | + }, |
| 67 | + { |
| 68 | + "code": "c", |
| 69 | + "description": "desc_c" |
| 70 | + } |
| 71 | + ], |
| 72 | + "ETHNICITY": [ |
| 73 | + { |
| 74 | + "code": "a", |
| 75 | + "description": "desc_a" |
| 76 | + }, |
| 77 | + { |
| 78 | + "code": "b", |
| 79 | + "description": "desc_b" |
| 80 | + }, |
| 81 | + { |
| 82 | + "code": "c", |
| 83 | + "description": "desc_c" |
| 84 | + } |
| 85 | + ], |
| 86 | + "GENDER": [ |
| 87 | + { |
| 88 | + "code": "a", |
| 89 | + "description": "desc_a" |
| 90 | + }, |
| 91 | + { |
| 92 | + "code": "b", |
| 93 | + "description": "desc_b" |
| 94 | + }, |
| 95 | + { |
| 96 | + "code": "c", |
| 97 | + "description": "desc_c" |
| 98 | + } |
| 99 | + ] |
| 100 | + }, |
| 101 | + "probationReferenceData": { |
| 102 | + "PHONE_TYPE": [ |
| 103 | + { |
| 104 | + "code": "a", |
| 105 | + "description": "desc_a" |
| 106 | + }, |
| 107 | + { |
| 108 | + "code": "b", |
| 109 | + "description": "desc_b" |
| 110 | + }, |
| 111 | + { |
| 112 | + "code": "c", |
| 113 | + "description": "desc_c" |
| 114 | + } |
| 115 | + ], |
| 116 | + "REGISTER_TYPE": [ |
| 117 | + { |
| 118 | + "code": "a", |
| 119 | + "description": "desc_a" |
| 120 | + }, |
| 121 | + { |
| 122 | + "code": "b", |
| 123 | + "description": "desc_b" |
| 124 | + }, |
| 125 | + { |
| 126 | + "code": "c", |
| 127 | + "description": "desc_c" |
| 128 | + } |
| 129 | + ], |
| 130 | + "ETHNICITY": [ |
| 131 | + { |
| 132 | + "code": "a", |
| 133 | + "description": "desc_a" |
| 134 | + }, |
| 135 | + { |
| 136 | + "code": "b", |
| 137 | + "description": "desc_b" |
| 138 | + }, |
| 139 | + { |
| 140 | + "code": "c", |
| 141 | + "description": "desc_c" |
| 142 | + } |
| 143 | + ], |
| 144 | + "GENDER": [ |
| 145 | + { |
| 146 | + "code": "a", |
| 147 | + "description": "desc_a" |
| 148 | + }, |
| 149 | + { |
| 150 | + "code": "b", |
| 151 | + "description": "desc_b" |
| 152 | + }, |
| 153 | + { |
| 154 | + "code": "c", |
| 155 | + "description": "desc_c" |
| 156 | + } |
| 157 | + ] |
| 158 | + }, |
| 159 | + "errors": [] |
| 160 | + }""", |
| 161 | + ), |
| 162 | + ], |
| 163 | + ), |
| 164 | + ], |
| 165 | + ), |
| 166 | + ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]), |
| 167 | + ], |
| 168 | + ) |
| 169 | + fun getReferenceData(): Response<ReferenceData?> { |
| 170 | + return referenceDataService.referenceData() |
| 171 | + } |
| 172 | +} |
0 commit comments