|
| 1 | +package uk.gov.justice.digital.hmpps.personintegrationapi.common.client.response |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonInclude |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema |
| 5 | +import uk.gov.justice.digital.hmpps.personintegrationapi.common.dto.ReferenceDataValue |
| 6 | +import uk.gov.justice.digital.hmpps.personintegrationapi.common.mapper.mapRefDataDescription |
| 7 | +import java.time.LocalDate |
| 8 | + |
| 9 | +@JsonInclude(JsonInclude.Include.NON_NULL) |
| 10 | +@Schema(description = "Profile Code Type") |
| 11 | +data class ProfileCodeType( |
| 12 | + @Schema(description = "Profile Type", required = true) |
| 13 | + val type: String, |
| 14 | + |
| 15 | + @Schema(description = "Category", required = true) |
| 16 | + val category: String, |
| 17 | + |
| 18 | + @Schema(description = "Description") |
| 19 | + val description: String? = null, |
| 20 | + |
| 21 | + @Schema(description = "Mandatory Flag", required = true) |
| 22 | + val mandatory: Boolean = false, |
| 23 | + |
| 24 | + @Schema(description = "Update Allowed Flag", required = true) |
| 25 | + val updateAllowed: Boolean = true, |
| 26 | + |
| 27 | + @Schema(description = "Code Value Type", required = true) |
| 28 | + val codeValueType: String, |
| 29 | + |
| 30 | + @Schema(description = "Active Flag", required = true) |
| 31 | + val active: Boolean = true, |
| 32 | + |
| 33 | + @Schema(description = "Expiry Date") |
| 34 | + val endDate: LocalDate? = null, |
| 35 | + |
| 36 | + @Schema(description = "List Sequence", required = true) |
| 37 | + val listSequence: Int = 99, |
| 38 | +) |
| 39 | + |
| 40 | +@JsonInclude(JsonInclude.Include.NON_NULL) |
| 41 | +@Schema(description = "Profile Code ID") |
| 42 | +data class ProfileCodeId( |
| 43 | + @Schema(description = "Type", required = true) |
| 44 | + val type: ProfileCodeType, |
| 45 | + |
| 46 | + @Schema(description = "Code", required = true) |
| 47 | + val code: String, |
| 48 | +) |
| 49 | + |
| 50 | +@JsonInclude(JsonInclude.Include.NON_NULL) |
| 51 | +@Schema(description = "Profile Code") |
| 52 | +data class ProfileCode( |
| 53 | + @Schema(description = "ID", required = true) |
| 54 | + val id: ProfileCodeId, |
| 55 | + |
| 56 | + @Schema(description = "Description") |
| 57 | + val description: String? = null, |
| 58 | + |
| 59 | + @Schema(description = "Update Allowed Flag", required = true) |
| 60 | + val updateAllowed: Boolean = true, |
| 61 | + |
| 62 | + @Schema(description = "Active Flag", required = true) |
| 63 | + val active: Boolean = true, |
| 64 | + |
| 65 | + @Schema(description = "Expiry Date") |
| 66 | + val endDate: LocalDate? = null, |
| 67 | + |
| 68 | + @Schema(description = "List Sequence", required = true) |
| 69 | + val listSequence: Int = 99, |
| 70 | +) { |
| 71 | + fun toReferenceDataValue(): ReferenceDataValue = ReferenceDataValue( |
| 72 | + id = "${id.type.type}_${id.code}", |
| 73 | + code = id.code, |
| 74 | + description = mapRefDataDescription(id.type.type, id.code, description), |
| 75 | + ) |
| 76 | +} |
0 commit comments