Skip to content

Commit

Permalink
Merge pull request #453 from DFE-Digital/feature/155067-integrate-get…
Browse files Browse the repository at this point in the history
…-construct-projects

155067: integrate get construct projects
  • Loading branch information
mikestock-nimble authored Feb 5, 2024
2 parents 6293b4a + 23a3d8f commit e3c34ae
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
31 changes: 17 additions & 14 deletions TramsDataApi.Test/FakeApi/FakeMfspApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,29 @@ public class FakeMfspApi

public void Start()
{
_server = new WebHostBuilder().UseKestrel(x => x.ListenLocalhost(5003)).Configure(app =>
_server = new WebHostBuilder().UseKestrel(x => x.ListenLocalhost(6784)).Configure(app =>
{
app.Run(async context =>
{
if (context.Request.Method == HttpMethods.Get && context.Request.Path == "/v2/fss/projects")
if (context.Request.Method == HttpMethods.Get && context.Request.Path == "/api/v1/construct/projects")
{
var response = new List<FssProjectResponse>()
var response = new ApiResponseV2<FssProjectResponse>()
{
new FssProjectResponse()
Data = new List<FssProjectResponse>()
{
CurrentFreeSchoolName = "This is my free school",
AgeRange = "5-11",
ProjectStatus = "Open",
},
new FssProjectResponse()
{
CurrentFreeSchoolName = "This is another free school",
AgeRange = "11-16",
ProjectStatus = "Open",
},
new FssProjectResponse()
{
CurrentFreeSchoolName = "This is my free school",
AgeRange = "5-11",
ProjectStatus = "Open",
},
new FssProjectResponse()
{
CurrentFreeSchoolName = "This is another free school",
AgeRange = "11-16",
ProjectStatus = "Open",
},
}
};

await context.Response.WriteAsJsonAsync(response);
Expand Down
2 changes: 1 addition & 1 deletion TramsDataApi.Test/integration_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"DefaultConnection": "Server=127.0.0.1,1433;Database=sip;User Id=sa;TrustServerCertificate=True;Password=StrongPassword905"
},
"Mfsp": {
"ApiEndpoint": "http://localhost:5003"
"ApiEndpoint": "http://localhost:6784"
},
"FeatureManagement": {
"IsGetProjectsFromMfspEnabled": true
Expand Down
2 changes: 2 additions & 0 deletions TramsDataApi/Configuration/MfspOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public class MfspOptions
{
public string ApiEndpoint { get; set; }

public string ApiKey { get; set; }
}
}
1 change: 1 addition & 0 deletions TramsDataApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void ConfigureServices(IServiceCollection services)
{
MfspOptions mfspOptions = GetTypedConfigurationFor<MfspOptions>();
client.BaseAddress = new Uri(mfspOptions.ApiEndpoint);
client.DefaultRequestHeaders.Add("ApiKey", mfspOptions.ApiKey);
});

services.AddScoped<ITrustGateway, TrustGateway>();
Expand Down
6 changes: 6 additions & 0 deletions TramsDataApi/TramsDataApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<UserSecretsId>1ce62ee2-ff0b-4f40-9066-cfbdae2e889f</UserSecretsId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="ServiceModels\**" />
<Content Remove="ServiceModels\**" />
Expand Down
4 changes: 2 additions & 2 deletions TramsDataApi/UseCases/GetAllFssProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public async Task<List<FssProjectResponse>> Execute()

if (useMfspApi)
{
var mfspProjects = await _mfspApiClient.Get<List<FssProjectResponse>>("/v2/fss/projects");
var mfspProjects = await _mfspApiClient.Get<ApiResponseV2<FssProjectResponse>>("/api/v1/construct/projects");

return mfspProjects;
return mfspProjects.Data.ToList();
}

return _fssProjectGateway.GetAll().Select(fssProject => FssProjectResponseFactory.Create(fssProject)).ToList();
Expand Down
3 changes: 2 additions & 1 deletion TramsDataApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
}
},
"Mfsp": {
"ApiEndpoint": "<insert mfsp endpoint>"
"ApiEndpoint": "<insert mfsp endpoint>",
"ApiKey": "<insert mfsp api key>"
},
"FeatureManagement": {
"IsGetProjectsFromMfspEnabled": false
Expand Down

0 comments on commit e3c34ae

Please sign in to comment.