-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8f80dc
commit 6c3f731
Showing
5 changed files
with
102 additions
and
0 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
92 changes: 92 additions & 0 deletions
92
src/Public.Api/Address/BackOffice/AddressBackOfficerController-CorrectRemoval.cs
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,92 @@ | ||
namespace Public.Api.Address.BackOffice | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AddressRegistry.Api.Oslo.Address.Detail; | ||
using Be.Vlaanderen.Basisregisters.Api.Exceptions; | ||
using Common.Infrastructure; | ||
using Common.Infrastructure.Extensions; | ||
using Infrastructure; | ||
using Infrastructure.Swagger; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Infrastructure; | ||
using RestSharp; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
using Swashbuckle.AspNetCore.Filters; | ||
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; | ||
|
||
public partial class AddressBackOfficeController | ||
{ | ||
public const string CorrectRemovalRoute = "adressen/{objectId}/acties/corrigeren/verwijdering"; | ||
|
||
/// <summary> | ||
/// Corrigeer de verwijdering van een adres (v2). | ||
/// </summary> | ||
/// <param name="objectId">Identificator van het adres.</param> | ||
/// <param name="actionContextAccessor"></param> | ||
/// <param name="problemDetailsHelper"></param> | ||
/// <param name="featureToggle"></param> | ||
/// <param name="ifMatch">If-Match header met ETag van de laatst gekende versie van het adres (optioneel).</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <response code="202">Als het ticket succesvol is aangemaakt.</response> | ||
/// <response code="400">Als uw verzoek foutieve data bevat.</response> | ||
/// <response code="401">Als u niet geauthenticeerd bent om deze actie uit te voeren.</response> | ||
/// <response code="403">Als u niet beschikt over de correcte rechten om deze actie uit te voeren.</response> | ||
/// <response code="404">Als het adres niet gevonden kan worden.</response> | ||
/// <response code="406">Als het gevraagde formaat niet beschikbaar is.</response> | ||
/// <response code="412">Als de If-Match header niet overeenkomt met de laatste ETag.</response> | ||
/// <response code="429">Als het aantal requests per seconde de limiet overschreven heeft.</response> | ||
/// <response code="500">Als er een interne fout is opgetreden.</response> | ||
/// <returns></returns> | ||
[ApiOrder(ApiOrder.Address.Edit + 16)] | ||
[ProducesResponseType(StatusCodes.Status202Accepted)] | ||
[ProducesResponseType(typeof(Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails), StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status412PreconditionFailed)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] | ||
[SwaggerResponseHeader(StatusCodes.Status202Accepted, "location", "string", "De URL van het aangemaakte ticket.")] | ||
[SwaggerResponseHeader(StatusCodes.Status202Accepted, "x-correlation-id", "string", "Correlatie identificator van de response.")] | ||
[SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status401Unauthorized, typeof(UnauthorizedOAuthResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status403Forbidden, typeof(ForbiddenOAuthResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status404NotFound, typeof(AddressNotFoundResponseExamples))] | ||
[SwaggerResponseExample(StatusCodes.Status412PreconditionFailed, typeof(PreconditionFailedResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status429TooManyRequests, typeof(TooManyRequestsResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamplesV2))] | ||
[SwaggerOperation(Description = "Correctie van de verwijdering van een adres. Gekoppelde busnummers worden niet mee gecorrigeerd.")] | ||
[HttpPost(CorrectRemovalRoute, Name = nameof(CorrectRemovalAddress))] | ||
public async Task<IActionResult> CorrectRemovalAddress( | ||
[FromRoute] int objectId, | ||
[FromServices] IActionContextAccessor actionContextAccessor, | ||
[FromServices] ProblemDetailsHelper problemDetailsHelper, | ||
[FromServices] CorrectRemovalAddressToggle featureToggle, | ||
[FromHeader(Name = HeaderNames.IfMatch)] string? ifMatch, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (!featureToggle.FeatureEnabled) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); | ||
|
||
RestRequest BackendRequest() => new RestRequest(CorrectRemovalRoute, Method.Post) | ||
.AddParameter("objectId", objectId, ParameterType.UrlSegment) | ||
.AddHeaderIfMatch(ifMatch) | ||
.AddHeaderAuthorization(actionContextAccessor); | ||
|
||
var value = await GetFromBackendWithBadRequestAsync( | ||
contentFormat.ContentType, | ||
BackendRequest, | ||
CreateDefaultHandleBadRequest(), | ||
problemDetailsHelper, | ||
cancellationToken: cancellationToken); | ||
|
||
return new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()); | ||
} | ||
} | ||
} |
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