generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a314845
commit 1337bbd
Showing
59 changed files
with
979 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...k/gov/justice/digital/hmpps/healthandmedication/annotation/ReferenceDataListValidation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.annotation | ||
|
||
import jakarta.validation.Constraint | ||
import jakarta.validation.Payload | ||
import uk.gov.justice.digital.hmpps.healthandmedication.validator.ReferenceDataListValidator | ||
import kotlin.reflect.KClass | ||
|
||
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Constraint(validatedBy = [ReferenceDataListValidator::class]) | ||
annotation class ReferenceDataListValidation( | ||
val domains: Array<String> = [], | ||
val message: String = "The supplied array must either be empty or contain reference data codes of the correct domain.", | ||
val groups: Array<KClass<*>> = [], | ||
val payload: Array<KClass<out Payload>> = [], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...tlin/uk/gov/justice/digital/hmpps/healthandmedication/client/prisonapi/PrisonApiClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.client.prisonapi | ||
|
||
import org.springframework.beans.factory.annotation.Qualifier | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import uk.gov.justice.digital.hmpps.healthandmedication.client.prisonapi.request.PrisonApiSmokerStatusUpdate | ||
import uk.gov.justice.digital.hmpps.healthandmedication.config.DownstreamServiceException | ||
|
||
@Component | ||
class PrisonApiClient(@Qualifier("prisonApiWebClient") private val webClient: WebClient) { | ||
fun updateSmokerStatus(offenderNo: String, updateSmokerStatus: PrisonApiSmokerStatusUpdate) = try { | ||
webClient | ||
.put() | ||
.uri("/api/offenders/{offenderNo}/smoker", offenderNo) | ||
.bodyValue(updateSmokerStatus) | ||
.retrieve() | ||
.toBodilessEntity() | ||
.block() | ||
} catch (e: Exception) { | ||
throw DownstreamServiceException("Update smoker status request failed", e) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...digital/hmpps/healthandmedication/client/prisonapi/request/PrisonApiSmokerStatusUpdate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.client.prisonapi.request | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
enum class PrisonApiSmokerStatus { | ||
Y, | ||
N, | ||
V, | ||
} | ||
|
||
@Schema(description = "Update to prisoner's smoker status") | ||
data class PrisonApiSmokerStatusUpdate( | ||
@Schema( | ||
description = "The smoker status code ('Y' for 'Yes', 'N' for 'No', 'V' for 'Vaper/NRT Only')", | ||
example = "Y", | ||
allowableValues = ["Y", "N", "V"], | ||
required = true, | ||
nullable = true, | ||
) | ||
val smokerStatus: PrisonApiSmokerStatus?, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../client/prisonersearch/dto/PrisonerDto.kt → ...nt/prisonersearch/response/PrisonerDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...onersearch/dto/PrisonerSearchResultDto.kt → ...earch/response/PrisonerSearchResultDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...pps/healthandmedication/config/UserEnhancedOAuth2ClientCredentialGrantRequestConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package uk.gov.justice.digital.hmpps.personintegrationapi.config | ||
|
||
import org.springframework.http.HttpMethod | ||
import org.springframework.http.RequestEntity | ||
import org.springframework.security.oauth2.client.endpoint.OAuth2ClientCredentialsGrantRequest | ||
import org.springframework.security.oauth2.client.endpoint.OAuth2ClientCredentialsGrantRequestEntityConverter | ||
import org.springframework.util.MultiValueMap | ||
import java.util.Objects | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
class UserEnhancedOAuth2ClientCredentialGrantRequestConverter : OAuth2ClientCredentialsGrantRequestEntityConverter() { | ||
|
||
fun enhanceWithUsername( | ||
grantRequest: OAuth2ClientCredentialsGrantRequest?, | ||
username: String?, | ||
): RequestEntity<Any> { | ||
val request = super.convert(grantRequest) | ||
val headers = request.headers | ||
val body = Objects.requireNonNull(request).body | ||
val formParameters = body as MultiValueMap<String, Any> | ||
if (username != null) { | ||
formParameters.add("username", username) | ||
} | ||
return RequestEntity(formParameters, headers, HttpMethod.POST, request.url) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
...kotlin/uk/gov/justice/digital/hmpps/healthandmedication/dto/response/FoodAllergyValues.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/kotlin/uk/gov/justice/digital/hmpps/healthandmedication/dto/response/HealthDto.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...kotlin/uk/gov/justice/digital/hmpps/healthandmedication/mapper/ReferenceDataCodeMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tlin/uk/gov/justice/digital/hmpps/healthandmedication/mapper/ReferenceDataDomainMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.