generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API method to return the Review schedule (#528)
* API method to return the Review schedule * API method to return the Review schedule * API method to return the Review schedule * added permissions
- Loading branch information
1 parent
4eb82bc
commit 1caa0b6
Showing
9 changed files
with
105 additions
and
4 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
18 changes: 18 additions & 0 deletions
18
...in/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/ReviewSchedule.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,18 @@ | ||
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.time.LocalDate | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.USE_DEFAULTS) | ||
data class ReviewSchedule( | ||
@Schema( | ||
description = "An ISO-8601 date representing when the Review should be completed by.", | ||
example = "2023-09-01", | ||
) | ||
val deadlineDate: LocalDate? = null, | ||
val nomisNumber: String? = null, | ||
val description: String? = null, | ||
) |
30 changes: 30 additions & 0 deletions
30
...v/justice/digital/hmpps/hmppsintegrationapi/services/GetReviewScheduleForPersonService.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,30 @@ | ||
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.services | ||
|
||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Service | ||
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways.PLPGateway | ||
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response | ||
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ReviewSchedule | ||
import java.time.LocalDate | ||
|
||
@Service | ||
class GetReviewScheduleForPersonService( | ||
@Autowired val plpGateway: PLPGateway, | ||
@Autowired val getPersonService: GetPersonService, | ||
) { | ||
fun execute(hmppsId: String): Response<ReviewSchedule> { | ||
val response = getPersonService.getNomisNumber(hmppsId = hmppsId) | ||
|
||
response.data?.nomisNumber?.let { | ||
return Response( | ||
ReviewSchedule( | ||
deadlineDate = LocalDate.now().plusMonths(1), | ||
nomisNumber = it, | ||
description = "This is a hardcoded response.", | ||
), | ||
) | ||
// return plpGateway.getReviewSchedule(it) // <-- this will be call the PLP service once the downstream code is written | ||
} | ||
return Response(ReviewSchedule(), response.errors) | ||
} | ||
} |
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
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