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

Trust endpoints annotations #404

Merged
merged 1 commit into from
Oct 25, 2023
Merged
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
19 changes: 19 additions & 0 deletions TramsDataApi/Controllers/V3/TrustsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Swashbuckle.AspNetCore.Annotations;
using TramsDataApi.ResponseModels;
using TramsDataApi.UseCases;

namespace TramsDataApi.Controllers.V3
{
/// <summary>
/// Manages operations related to trusts using the Master schema.
/// </summary>
[ApiVersion("3.0")]
[ApiController]
[Route("v{version:apiVersion}/")]
[SwaggerTag("Operations related to Trusts using the Master schema")]
public class TrustsController : ControllerBase
{
private readonly IGetMstrTrustByUkprn _getMstrTrustByUkPrn;
Expand All @@ -23,8 +28,16 @@ public TrustsController(IGetMstrTrustByUkprn getMstrTrustByUkPrn, IMstrSearchTru
_logger = logger;
}

/// <summary>
/// Searches for trusts based on given criteria.
/// </summary>
/// <remarks>
/// Search can be performed using the groupName, ukPrn, and companiesHouseNumber parameters.
/// </remarks>
[HttpGet("trusts")]
[MapToApiVersion("3.0")]
[SwaggerOperation(Summary = "Search Trusts", Description = "Search for trusts using the specified parameters, within the Master schema.")]
[SwaggerResponse(200, "Successfully found and returned the list of trusts.")]
public ActionResult<ApiResponseV2<TrustSummaryResponse>> SearchTrusts(string groupName, string ukPrn, string companiesHouseNumber,
int page = 1, int count = 50, bool includeEstablishments = true)
{
Expand All @@ -50,9 +63,15 @@ public ActionResult<ApiResponseV2<TrustSummaryResponse>> SearchTrusts(string gro
return new OkObjectResult(response);
}

/// <summary>
/// Retrieves a specific trust by UKPRN.
/// </summary>
[HttpGet]
[Route("trust/{ukprn}")]
[MapToApiVersion("3.0")]
[SwaggerOperation(Summary = "Get Trust By UKPRN", Description = "Retrieve a single trust by its UKPRN.")]
[SwaggerResponse(200, "Successfully retrieved the trust.")]
[SwaggerResponse(404, "The trust was not found.")]
public ActionResult<ApiSingleResponseV2<MasterTrustResponse>> GetTrustByUkPrn(string ukprn)
{
_logger.LogInformation("Attempting to get trust by UKPRN {prn}", ukprn);
Expand Down