Skip to content

Commit

Permalink
change endpoint from /learner-events/nomisId to /match/{nomisId}/lear…
Browse files Browse the repository at this point in the history
…ner-events (#113)

* feat(*): change endpoint from /learner-events/nomisId to /match/{nomisId}/learner-events

* feat(*): remove call to audit service on learners endpoint

* feat(*): address review comments
  • Loading branch information
malaw-moj authored Mar 3, 2025
1 parent b650a05 commit fdae689
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 531 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.parameters.RequestBody
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.security.SecurityRequirement
import uk.gov.justice.digital.hmpps.learnerrecordsapi.config.Roles.ROLE_LEARNERS_RO
import uk.gov.justice.digital.hmpps.learnerrecordsapi.config.Roles.ROLE_LEARNERS_UI
import uk.gov.justice.digital.hmpps.learnerrecordsapi.models.response.LearnerEventsResponse
import uk.gov.justice.hmpps.kotlin.common.ErrorResponse
Expand Down Expand Up @@ -219,167 +218,3 @@ import uk.gov.justice.hmpps.kotlin.common.ErrorResponse
],
)
annotation class LearnerEventsApi

@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@Operation(
summary = "Get learning events by Nomis ID",
description = "Get personal learning records and events by Nomis ID",
parameters = [Parameter(name = "X-Username", `in` = ParameterIn.HEADER, required = true)],
requestBody = RequestBody(
description = "Nomis ID of the learner",
required = true,
content = [
Content(
mediaType = "application/json",
examples = [
ExampleObject(
value = """
{
"nomisId": "123456"
}
""",
),
],
),
],
),
security = [SecurityRequirement(name = ROLE_LEARNERS_RO)],
responses = [
ApiResponse(
responseCode = "200",
description = "The request was successful and a response was returned.",
content = [
Content(
mediaType = "application/json",
schema = Schema(implementation = LearnerEventsResponse::class),
examples = [
ExampleObject(
name = "Exact Match Response",
value = """
{
"searchParameters": {
"givenName": "Sean",
"familyName": "Findlay",
"uln": "1174112637",
"dateOfBirth": "1980-11-01",
"gender": "MALE"
},
"responseType": "Exact Match",
"foundUln": "1174112637",
"incomingUln": "1174112637",
"learnerRecord": [
{
"id": "2931",
"achievementProviderUkprn": "10030488",
"achievementProviderName": "LUTON PENTECOSTAL CHURCH",
"awardingOrganisationName": "UNKNOWN",
"qualificationType": "GCSE",
"subjectCode": "50079116",
"achievementAwardDate": "2011-10-24",
"credits": "0",
"source": "ILR",
"dateLoaded": "2012-05-31 16:47:04",
"underDataChallenge": "N",
"level": "",
"status": "F",
"subject": "GCSE in English Literature",
"grade": "9999999999",
"awardingOrganisationUkprn": "UNKNWN",
"collectionType": "W",
"returnNumber": "02",
"participationStartDate": "2011-10-02",
"participationEndDate": "2011-10-24"
}
]
}
""",
),
ExampleObject(
name = "Linked Learner Match Response",
value = """
{
"searchParameters": {
"givenName": "Connor",
"familyName": "Carroll",
"uln": "4444599390"
},
"responseType": "Linked Learner Match",
"foundUln": "6936002314",
"incomingUln": "4444599390",
"learnerRecord": [
{
"id": "4284",
"achievementProviderUkprn": "10032743",
"achievementProviderName": "PRIORSLEE PRIMARY SCHOOL ACADEMY TRUST",
"awardingOrganisationName": "UNKNOWN",
"qualificationType": "NVQ/GNVQ Key Skills Unit",
"subjectCode": "1000323X",
"achievementAwardDate": "2010-09-26",
"credits": "0",
"source": "ILR",
"dateLoaded": "2012-05-31 16:47:04",
"underDataChallenge": "N",
"level": "",
"status": "F",
"subject": "Key Skills in Application of Number - level 1",
"grade": "9999999999",
"awardingOrganisationUkprn": "UNKNWN",
"collectionType": "W",
"returnNumber": "02",
"participationStartDate": "2010-09-01",
"participationEndDate": "2010-09-26"
}
]
}
""",
),
ExampleObject(
name = "Learner opted to not share data Response",
value = """
{
"searchParameters": {
"givenName": "John",
"familyName": "Smith",
"uln": "1026922983"
},
"responseType": "Learner opted to not share data",
"foundUln": "1026922983",
"incomingUln": "1026922983",
"learnerRecord": []
}
""",
),
ExampleObject(
name = "Learner could not be verified Response",
value = """
{
"searchParameters": {
"givenName": "John",
"familyName": "Smith",
"uln": "1174112637"
},
"responseType": "Learner could not be verified",
"foundUln": "",
"incomingUln": "1174112637",
"learnerRecord": []
}
""",
),
],
),
],
),
ApiResponse(
responseCode = "401",
description = "Unauthorized to access this endpoint",
content = [Content(mediaType = "application/json", schema = Schema(implementation = ErrorResponse::class))],
),
ApiResponse(
responseCode = "403",
description = "Forbidden to access this endpoint",
content = [Content(mediaType = "application/json", schema = Schema(implementation = ErrorResponse::class))],
),
],
)
annotation class LearnerEventsByNomisIdApi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.security.SecurityRequirement
import uk.gov.justice.digital.hmpps.learnerrecordsapi.config.Roles.ROLE_LEARNERS_UI
import uk.gov.justice.digital.hmpps.learnerrecordsapi.models.request.ConfirmMatchRequest
import uk.gov.justice.digital.hmpps.learnerrecordsapi.models.response.LearnerEventsResponse
import uk.gov.justice.hmpps.kotlin.common.ErrorResponse

@Target(AnnotationTarget.FUNCTION)
Expand Down Expand Up @@ -61,3 +62,150 @@ import uk.gov.justice.hmpps.kotlin.common.ErrorResponse
],
)
annotation class MatchConfirmApi

@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@Operation(
summary = "Get learning events by Nomis ID",
description = "Get personal learning records and events by Nomis ID",
parameters = [
Parameter(name = "X-Username", `in` = ParameterIn.HEADER, required = true),
Parameter(name = "nomisId", `in` = ParameterIn.PATH, required = true),
],
security = [SecurityRequirement(name = "learner-records-search-read-only-role")],
responses = [
ApiResponse(
responseCode = "200",
description = "The request was successful and a response was returned.",
content = [
Content(
mediaType = "application/json",
schema = Schema(implementation = LearnerEventsResponse::class),
examples = [
ExampleObject(
name = "Exact Match Response",
value = """
{
"searchParameters": {
"givenName": "Sean",
"familyName": "Findlay",
"uln": "1174112637"
},
"responseType": "Exact Match",
"foundUln": "1174112637",
"incomingUln": "1174112637",
"learnerRecord": [
{
"id": "2931",
"achievementProviderUkprn": "10030488",
"achievementProviderName": "LUTON PENTECOSTAL CHURCH",
"awardingOrganisationName": "UNKNOWN",
"qualificationType": "GCSE",
"subjectCode": "50079116",
"achievementAwardDate": "2011-10-24",
"credits": "0",
"source": "ILR",
"dateLoaded": "2012-05-31 16:47:04",
"underDataChallenge": "N",
"level": "",
"status": "F",
"subject": "GCSE in English Literature",
"grade": "9999999999",
"awardingOrganisationUkprn": "UNKNWN",
"collectionType": "W",
"returnNumber": "02",
"participationStartDate": "2011-10-02",
"participationEndDate": "2011-10-24"
}
]
}
""",
),
ExampleObject(
name = "Linked Learner Match Response",
value = """
{
"searchParameters": {
"givenName": "Connor",
"familyName": "Carroll",
"uln": "4444599390"
},
"responseType": "Linked Learner Match",
"foundUln": "6936002314",
"incomingUln": "4444599390",
"learnerRecord": [
{
"id": "4284",
"achievementProviderUkprn": "10032743",
"achievementProviderName": "PRIORSLEE PRIMARY SCHOOL ACADEMY TRUST",
"awardingOrganisationName": "UNKNOWN",
"qualificationType": "NVQ/GNVQ Key Skills Unit",
"subjectCode": "1000323X",
"achievementAwardDate": "2010-09-26",
"credits": "0",
"source": "ILR",
"dateLoaded": "2012-05-31 16:47:04",
"underDataChallenge": "N",
"level": "",
"status": "F",
"subject": "Key Skills in Application of Number - level 1",
"grade": "9999999999",
"awardingOrganisationUkprn": "UNKNWN",
"collectionType": "W",
"returnNumber": "02",
"participationStartDate": "2010-09-01",
"participationEndDate": "2010-09-26"
}
]
}
""",
),
ExampleObject(
name = "Learner opted to not share data Response",
value = """
{
"searchParameters": {
"givenName": "John",
"familyName": "Smith",
"uln": "1026922983"
},
"responseType": "Learner opted to not share data",
"foundUln": "1026922983",
"incomingUln": "1026922983",
"learnerRecord": []
}
""",
),
ExampleObject(
name = "Learner could not be verified Response",
value = """
{
"searchParameters": {
"givenName": "John",
"familyName": "Smith",
"uln": "1174112637"
},
"responseType": "Learner could not be verified",
"foundUln": "",
"incomingUln": "1174112637",
"learnerRecord": []
}
""",
),
],
),
],
),
ApiResponse(
responseCode = "401",
description = "Unauthorized to access this endpoint",
content = [Content(mediaType = "application/json", schema = Schema(implementation = ErrorResponse::class))],
),
ApiResponse(
responseCode = "403",
description = "Forbidden to access this endpoint",
content = [Content(mediaType = "application/json", schema = Schema(implementation = ErrorResponse::class))],
),
],
)
annotation class LearnerEventsByNomisIdApi
Loading

0 comments on commit fdae689

Please sign in to comment.