generated from ministryofjustice/template-repository
-
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.
MAN-319 PI-2749: MPOP Activity Search API
- Loading branch information
Showing
14 changed files
with
242 additions
and
9 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
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
21 changes: 21 additions & 0 deletions
21
...ects/manage-supervision-and-delius/src/dev/resources/simulations/mappings/hmpps-auth.json
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 @@ | ||
{ | ||
"request": { | ||
"method": "POST", | ||
"urlPath": "/auth/oauth/token" | ||
}, | ||
"response": { | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"status": 200, | ||
"jsonBody": { | ||
"access_token": "token", | ||
"token_type": "bearer", | ||
"expires_in": 9999999999, | ||
"scope": "read write", | ||
"sub": "probation-integration-dev", | ||
"auth_source": "none", | ||
"iss": "https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer" | ||
} | ||
} | ||
} |
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
22 changes: 21 additions & 1 deletion
22
...-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/activity/PersonActivity.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 |
---|---|---|
@@ -1,8 +1,28 @@ | ||
package uk.gov.justice.digital.hmpps.api.model.activity | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat | ||
import uk.gov.justice.digital.hmpps.api.model.PersonSummary | ||
import java.time.LocalDate | ||
|
||
data class PersonActivity( | ||
val personSummary: PersonSummary, | ||
val activities: List<Activity> | ||
) | ||
) | ||
|
||
data class PersonActivitySearchResponse( | ||
val size: Int, | ||
val page: Int, | ||
val totalResults: Long, | ||
val totalPages: Int, | ||
val personSummary: PersonSummary, | ||
val activities: List<Activity> | ||
) | ||
|
||
data class PersonActivitySearchRequest( | ||
val keywords: String? = "", | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
val dateFrom: LocalDate? = null, | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
val dateTo: LocalDate? = null, | ||
val filters: List<String> = emptyList(), | ||
) |
40 changes: 40 additions & 0 deletions
40
...n-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/client/ProbationSearchClient.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,40 @@ | ||
package uk.gov.justice.digital.hmpps.client | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.service.annotation.PostExchange | ||
import java.time.LocalDate | ||
|
||
interface ProbationSearchClient { | ||
@PostExchange(url = "/search/activity") | ||
fun contactSearch( | ||
@RequestBody body: ActivitySearchRequest, | ||
@RequestParam page: Int = 0, | ||
@RequestParam size: Int = 10): ContactSearchResponse | ||
} | ||
|
||
data class ActivitySearchRequest( | ||
val crn: String, | ||
val keywords: String? = "", | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
val dateFrom: LocalDate? = null, | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
val dateTo: LocalDate? = null, | ||
val filters: List<String> = emptyList(), | ||
) | ||
|
||
|
||
data class ContactSearchResponse( | ||
val size: Int, | ||
val page: Int, | ||
val totalResults: Long, | ||
val totalPages: Int, | ||
val results: List<ContactSearchResult>, | ||
) | ||
|
||
data class ContactSearchResult( | ||
val crn: String, | ||
val id: Long, | ||
val highlights: Map<String, List<String>> = mapOf() | ||
) |
16 changes: 16 additions & 0 deletions
16
...vision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.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.config | ||
|
||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.web.client.RestClient | ||
import uk.gov.justice.digital.hmpps.client.ProbationSearchClient | ||
import uk.gov.justice.digital.hmpps.config.security.createClient | ||
|
||
@Configuration | ||
class RestClientConfig(private val oauth2Client: RestClient) { | ||
|
||
@Bean | ||
fun probationSearchClient(@Value("\${integrations.probation-search.url}") apiBaseUrl: String): ProbationSearchClient = | ||
createClient(oauth2Client.mutate().baseUrl(apiBaseUrl).build()) | ||
} |
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
39 changes: 38 additions & 1 deletion
39
...vision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ActivityService.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