Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't share API models across versions #1465

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

[AutoMap(typeof(Core.SharedModels.AlertInfo))]
public record AlertInfo
{
public required AlertType AlertType { get; init; }
public required string DqtSanctionCode { get; init; }
public required DateOnly? StartDate { get; init; }
public required DateOnly? EndDate { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

public enum AlertType
{
Prohibition,
// Only exposing Prohibitions for now
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

public enum InductionStatus
{
Exempt,
Fail,
FailedinWales,
InductionExtended,
InProgress,
NotYetCompleted,
Pass,
PassedinWales,
RequiredtoComplete,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

public enum IttOutcome
{
Pass,
Fail,
Withdrawn,
Deferred,
DeferredForSkillsTests,
ApplicationReceived,
ApplicationUnsuccessful,
Approved,
Info,
InTraining,
NoResultSubmitted,
UnderAssessment,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

public enum IttProgrammeType
{
Apprenticeship,
AssessmentOnlyRoute,
Core,
CoreFlexible,
EYITTAssessmentOnly,
EYITTGraduateEmploymentBased,
EYITTGraduateEntry,
EYITTSchoolDirectEarlyYears,
EYITTUndergraduate,
FutureTeachingScholars,
GraduateTeacherProgramme,
HEI,
LicensedTeacherProgramme,
OverseasTrainedTeacherProgramme,
RegisteredTeacherProgramme,
SchoolDirectTrainingProgramme,
SchoolDirectTrainingProgrammeSalaried,
SchoolDirectTrainingProgrammeSelfFunded,
TeachFirstProgramme,
TeachFirstProgrammeCC,
UndergraduateOptIn,
ProviderLedPostgrad,
ProviderLedUndergrad,
InternationalQualifiedTeacherStatus,
HighPotentialITT
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

[AutoMap(typeof(Core.SharedModels.NameInfo))]
public record NameInfo
{
public required string FirstName { get; init; }
public required string MiddleName { get; init; }
public required string LastName { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

public enum NpqQualificationType
{
NPQEL,
NPQEYL,
NPQH,
NPQLBC,
NPQLL,
NPQLT,
NPQLTD,
NPQML,
NPQSL,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TeachingRecordSystem.Api.V3.V20240416.ApiModels;

[AutoMap(typeof(Core.SharedModels.SanctionInfo))]
public record SanctionInfo
{
public required string Code { get; init; }
public required DateOnly? StartDate { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using TeachingRecordSystem.Api.Infrastructure.ModelBinding;
using TeachingRecordSystem.Api.Infrastructure.Security;
using TeachingRecordSystem.Api.V3.Core.Operations;
using GetTeacherDtoVersion = TeachingRecordSystem.Api.V3.V20240101;
using TeachingRecordSystem.Api.V3.V20240416.Requests;
using TeachingRecordSystem.Api.V3.V20240416.Responses;

namespace TeachingRecordSystem.Api.V3.V20240416.Controllers;

Expand All @@ -16,13 +17,13 @@ public class TeachersController(IMapper mapper) : ControllerBase
OperationId = "GetTeacherByTrn",
Summary = "Get teacher details by TRN",
Description = "Gets the details of the teacher corresponding to the given TRN.")]
[ProducesResponseType(typeof(GetTeacherDtoVersion.Responses.GetTeacherResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(GetTeacherResponse), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
[Authorize(Policy = AuthorizationPolicies.GetPerson)]
public async Task<IActionResult> Get(
[FromRoute] string trn,
[FromQuery, ModelBinder(typeof(FlagsEnumStringListModelBinder)), SwaggerParameter("The additional properties to include in the response.")] GetTeacherDtoVersion.Requests.GetTeacherRequestIncludes? include,
[FromQuery, ModelBinder(typeof(FlagsEnumStringListModelBinder)), SwaggerParameter("The additional properties to include in the response.")] GetTeacherRequestIncludes? include,
[FromQuery, SwaggerParameter("Adds an additional check that the record has the specified dateOfBirth, if provided.")] DateOnly? dateOfBirth,
[FromServices] GetPersonHandler handler)
{
Expand All @@ -38,7 +39,7 @@ public async Task<IActionResult> Get(
return NotFound();
}

var response = mapper.Map<GetTeacherDtoVersion.Responses.GetTeacherResponse>(result);
var response = mapper.Map<GetTeacherResponse>(result);
return Ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.ComponentModel;

namespace TeachingRecordSystem.Api.V3.V20240416.Requests;

[Flags]
[Description("Comma-separated list of data to include in response.")]
public enum GetTeacherRequestIncludes
{
None = 0,

Induction = 1 << 0,
InitialTeacherTraining = 1 << 1,
NpqQualifications = 1 << 2,
MandatoryQualifications = 1 << 3,
PendingDetailChanges = 1 << 4,
HigherEducationQualifications = 1 << 5,
Sanctions = 1 << 6,
Alerts = 1 << 7,
PreviousNames = 1 << 8,

[ExcludeFromSchema]
_AllowIdSignInWithProhibitions = 1 << 9,

All = Induction | InitialTeacherTraining | NpqQualifications | MandatoryQualifications | PendingDetailChanges | HigherEducationQualifications | Sanctions | Alerts | PreviousNames
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
using System.Text.Json.Serialization;
using AutoMapper.Configuration.Annotations;
using Optional;
using TeachingRecordSystem.Api.V3.Core.Operations;
using TeachingRecordSystem.Api.V3.V20240416.ApiModels;

namespace TeachingRecordSystem.Api.V3.V20240416.Responses;

[AutoMap(typeof(GetPersonResult))]
public record GetTeacherResponse
{
public required string Trn { get; init; }
public required string FirstName { get; init; }
public required string MiddleName { get; init; }
public required string LastName { get; init; }
public required DateOnly DateOfBirth { get; init; }
public required string? NationalInsuranceNumber { get; init; }
public required Option<bool> PendingNameChange { get; init; }
public required Option<bool> PendingDateOfBirthChange { get; init; }
[SourceMember("EmailAddress")]
public required string? Email { get; set; }
public required GetTeacherResponseQts? Qts { get; init; }
public required GetTeacherResponseEyts? Eyts { get; init; }
public required Option<GetTeacherResponseInduction?> Induction { get; init; }
public required Option<IReadOnlyCollection<GetTeacherResponseInitialTeacherTraining>> InitialTeacherTraining { get; init; }
public required Option<IReadOnlyCollection<GetTeacherResponseNpqQualification>> NpqQualifications { get; init; }
public required Option<IReadOnlyCollection<GetTeacherResponseMandatoryQualification>> MandatoryQualifications { get; init; }
public required Option<IReadOnlyCollection<GetTeacherResponseHigherEducationQualification>> HigherEducationQualifications { get; init; }
public required Option<IReadOnlyCollection<SanctionInfo>> Sanctions { get; init; }
public required Option<IReadOnlyCollection<AlertInfo>> Alerts { get; init; }
public required Option<IReadOnlyCollection<NameInfo>> PreviousNames { get; init; }
public required Option<bool> AllowIdSignInWithProhibitions { get; init; }
}

[AutoMap(typeof(GetPersonResultQts))]
public record GetTeacherResponseQts
{
public required DateOnly? Awarded { get; init; }
public required string CertificateUrl { get; init; }
public required string? StatusDescription { get; init; }
}

[AutoMap(typeof(GetPersonResultEyts))]
public record GetTeacherResponseEyts
{
public required DateOnly? Awarded { get; init; }
public required string CertificateUrl { get; init; }
public required string? StatusDescription { get; init; }
}

[AutoMap(typeof(GetPersonResultInduction))]
public record GetTeacherResponseInduction
{
public required DateOnly? StartDate { get; init; }
public required DateOnly? EndDate { get; init; }
public required InductionStatus? Status { get; init; }
public required string? StatusDescription { get; init; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public required string? CertificateUrl { get; init; }
public required IReadOnlyCollection<GetTeacherResponseInductionPeriod> Periods { get; init; }
}

[AutoMap(typeof(GetPersonResultInductionPeriod))]
public record GetTeacherResponseInductionPeriod
{
public required DateOnly? StartDate { get; init; }
public required DateOnly? EndDate { get; init; }
public required int? Terms { get; init; }
public required GetTeacherResponseInductionPeriodAppropriateBody? AppropriateBody { get; init; }
}

[AutoMap(typeof(GetPersonResultInductionPeriodAppropriateBody))]
public record GetTeacherResponseInductionPeriodAppropriateBody
{
public required string Name { get; init; }
}

[AutoMap(typeof(GetPersonResultInitialTeacherTraining))]
public record GetTeacherResponseInitialTeacherTraining
{
public required GetTeacherResponseInitialTeacherTrainingQualification? Qualification { get; init; }
public required DateOnly? StartDate { get; init; }
public required DateOnly? EndDate { get; init; }
public required IttProgrammeType? ProgrammeType { get; init; }
public required string? ProgrammeTypeDescription { get; init; }
public required IttOutcome? Result { get; init; }
public required GetTeacherResponseInitialTeacherTrainingAgeRange? AgeRange { get; init; }
public required GetTeacherResponseInitialTeacherTrainingProvider? Provider { get; init; }
public required IReadOnlyCollection<GetTeacherResponseInitialTeacherTrainingSubject> Subjects { get; init; }
}

[AutoMap(typeof(GetPersonResultInitialTeacherTrainingQualification))]
public record GetTeacherResponseInitialTeacherTrainingQualification
{
public required string Name { get; init; }
}

[AutoMap(typeof(GetPersonResultInitialTeacherTrainingAgeRange))]
public record GetTeacherResponseInitialTeacherTrainingAgeRange
{
public required string Description { get; init; }
}

[AutoMap(typeof(GetPersonResultInitialTeacherTrainingProvider))]
public record GetTeacherResponseInitialTeacherTrainingProvider
{
public required string Name { get; init; }
public required string Ukprn { get; init; }
}

[AutoMap(typeof(GetPersonResultInitialTeacherTrainingSubject))]
public record GetTeacherResponseInitialTeacherTrainingSubject
{
public required string Code { get; init; }
public required string Name { get; init; }
}

[AutoMap(typeof(GetPersonResultNpqQualification))]
public record GetTeacherResponseNpqQualification
{
public required DateOnly Awarded { get; init; }
public required GetTeacherResponseNpqQualificationType Type { get; init; }
public required string CertificateUrl { get; init; }
}

[AutoMap(typeof(GetPersonResultNpqQualificationType))]
public record GetTeacherResponseNpqQualificationType
{
public required NpqQualificationType Code { get; init; }
public required string Name { get; init; }
}

[AutoMap(typeof(GetPersonResultMandatoryQualification))]
public record GetTeacherResponseMandatoryQualification
{
public required DateOnly Awarded { get; init; }
public required string Specialism { get; init; }
}

[AutoMap(typeof(GetPersonResultHigherEducationQualification))]
public record GetTeacherResponseHigherEducationQualification
{
public required string? Name { get; init; }
public required DateOnly? Awarded { get; init; }
public required IReadOnlyCollection<GetTeacherResponseHigherEducationQualificationSubject> Subjects { get; init; }
}

[AutoMap(typeof(GetPersonResultHigherEducationQualificationSubject))]
public record GetTeacherResponseHigherEducationQualificationSubject
{
public required string Code { get; init; }
public required string Name { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace TeachingRecordSystem.Api.V3.V20240606.ApiModels;

[AutoMap(typeof(Core.SharedModels.AlertInfo))]
public record AlertInfo
{
public required AlertType AlertType { get; init; }
public required string DqtSanctionCode { get; init; }
public required DateOnly? StartDate { get; init; }
public required DateOnly? EndDate { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace TeachingRecordSystem.Api.V3.V20240606.ApiModels;

public enum AlertType
{
Prohibition,
// Only exposing Prohibitions for now
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TeachingRecordSystem.Api.V3.V20240606.ApiModels;

public enum InductionStatus
{
Exempt,
Fail,
FailedinWales,
InductionExtended,
InProgress,
NotYetCompleted,
Pass,
PassedinWales,
RequiredtoComplete,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace TeachingRecordSystem.Api.V3.V20240606.ApiModels;

public enum IttOutcome
{
Pass,
Fail,
Withdrawn,
Deferred,
DeferredForSkillsTests,
ApplicationReceived,
ApplicationUnsuccessful,
Approved,
Info,
InTraining,
NoResultSubmitted,
UnderAssessment,
}
Loading
Loading