-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: or-2031 registreer inschrijving when adding kbo verenigingen #633
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
60 changes: 60 additions & 0 deletions
60
src/AssociationRegistry.Admin.Api/Verenigingen/KboSync/KboSyncHistoriekController.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,60 @@ | ||
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync; | ||
|
||
using Be.Vlaanderen.Basisregisters.Api; | ||
using Be.Vlaanderen.Basisregisters.Api.Exceptions; | ||
using Historiek.Examples; | ||
using Infrastructure.Swagger.Annotations; | ||
using Marten; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using ResponseModels; | ||
using Schema.KboSync; | ||
using Swashbuckle.AspNetCore.Filters; | ||
using System.Threading.Tasks; | ||
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; | ||
|
||
[ApiVersion("1.0")] | ||
[AdvertiseApiVersions("1.0")] | ||
[ApiRoute("verenigingen")] | ||
[ApiExplorerSettings(IgnoreApi = true)] | ||
[Authorize(Policy = Program.SuperAdminPolicyName)] | ||
public class KboSyncHistoriekController : ApiController | ||
{ | ||
private readonly KboSyncHistoriekResponseMapper _mapper; | ||
|
||
public KboSyncHistoriekController(KboSyncHistoriekResponseMapper mapper) | ||
{ | ||
_mapper = mapper; | ||
} | ||
|
||
/// <summary> | ||
/// Vraag de historiek van de KBO sync op. | ||
/// </summary> | ||
/// <param name="documentStore"></param> | ||
/// <param name="problemDetailsHelper"></param> | ||
/// <response code="200">De historiek van de KBO sync</response> | ||
/// <response code="500">Er is een interne fout opgetreden.</response> | ||
[HttpGet("kbo/historiek")] | ||
[SwaggerResponseExample(StatusCodes.Status200OK, typeof(HistoriekResponseExamples))] | ||
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] | ||
[ProducesResponseType(typeof(KboSyncHistoriekResponse), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] | ||
[ProducesJson] | ||
public async Task<IActionResult> GetKboSyncHistoriek( | ||
[FromServices] IDocumentStore documentStore, | ||
[FromServices] ProblemDetailsHelper problemDetailsHelper | ||
) | ||
{ | ||
await using var session = documentStore.LightweightSession(); | ||
|
||
var gebeurtenissen = await session | ||
.Query<BeheerKboSyncHistoriekGebeurtenisDocument>() | ||
.OrderByDescending(nameof(BeheerKboSyncHistoriekGebeurtenisDocument.Sequence)) | ||
.ToListAsync(); | ||
|
||
var response = _mapper.Map(gebeurtenissen); | ||
|
||
return Ok(response); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/AssociationRegistry.Admin.Api/Verenigingen/KboSync/KboSyncHistoriekResponseMapper.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,29 @@ | ||
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync; | ||
|
||
using Infrastructure.ConfigurationBindings; | ||
using ResponseModels; | ||
using Schema.KboSync; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
public class KboSyncHistoriekResponseMapper | ||
{ | ||
private readonly AppSettings _appSettings; | ||
|
||
public KboSyncHistoriekResponseMapper(AppSettings appSettings) | ||
{ | ||
_appSettings = appSettings; | ||
} | ||
|
||
public KboSyncHistoriekResponse Map(IEnumerable<BeheerKboSyncHistoriekGebeurtenisDocument> gebeurtenissen) | ||
=> new(gebeurtenissen.Select(Map).ToArray()); | ||
|
||
private static KboSyncHistoriekGebeurtenisResponse Map(BeheerKboSyncHistoriekGebeurtenisDocument gebeurtenisDocument) | ||
=> new() | ||
{ | ||
Kbonummer = gebeurtenisDocument.Kbonummer, | ||
VCode = gebeurtenisDocument.VCode, | ||
Beschrijving = gebeurtenisDocument.Beschrijving, | ||
Tijdstip = gebeurtenisDocument.Tijdstip, | ||
}; | ||
} |
24 changes: 24 additions & 0 deletions
24
...stry.Admin.Api/Verenigingen/KboSync/ResponseModels/KboSyncHistoriekGebeurtenisResponse.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,24 @@ | ||
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync.ResponseModels; | ||
|
||
using System.Runtime.Serialization; | ||
|
||
/// <summary>Een gebeurtenis van een vereniging</summary> | ||
[DataContract] | ||
public class KboSyncHistoriekGebeurtenisResponse | ||
{ | ||
/// <summary>Het KBO nummer waarop de gebeurtenis plaatsvond</summary> | ||
[DataMember(Name = "kbonummer")] | ||
public string Kbonummer { get; set; } = null!; | ||
|
||
/// <summary>De unieke identificatie code van deze vereniging</summary> | ||
[DataMember(Name = "vCode")] | ||
public string VCode { get; init; } = null!; | ||
|
||
/// <summary>De beschrijving van de gebeurtenis</summary> | ||
[DataMember(Name = "beschrijving")] | ||
public string Beschrijving { get; set; } = null!; | ||
|
||
/// <summary>Het tijdstip waarop de gebeurtenis plaatsvond</summary> | ||
[DataMember(Name = "tijdstip")] | ||
public string Tijdstip { get; set; } = null!; | ||
} |
14 changes: 14 additions & 0 deletions
14
...ciationRegistry.Admin.Api/Verenigingen/KboSync/ResponseModels/KboSyncHistoriekResponse.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,14 @@ | ||
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync.ResponseModels; | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Runtime.Serialization; | ||
|
||
/// <summary>Alle gebeurtenissen van deze vereniging</summary> | ||
[DataContract] | ||
public class KboSyncHistoriekResponse : ReadOnlyCollection<KboSyncHistoriekGebeurtenisResponse> | ||
{ | ||
public KboSyncHistoriekResponse(IList<KboSyncHistoriekGebeurtenisResponse> gebeurtenissen) : base(gebeurtenissen) | ||
{ | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...tionRegistry.Admin.ProjectionHost/Projections/KboSync/BeheerKboSyncHistoriekProjection.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,24 @@ | ||
namespace AssociationRegistry.Admin.ProjectionHost.Projections.KboSync; | ||
|
||
using Events; | ||
using Framework; | ||
using Marten.Events; | ||
using Marten.Events.Projections; | ||
using Schema.KboSync; | ||
|
||
public class BeheerKboSyncHistoriekProjection : EventProjection | ||
{ | ||
public BeheerKboSyncHistoriekProjection() | ||
{ | ||
Project<IEvent<VerenigingWerdIngeschrevenOpWijzigingenUitKbo>>((geregistreerd, operations) => | ||
{ | ||
operations.Insert(new BeheerKboSyncHistoriekGebeurtenisDocument( | ||
geregistreerd.Sequence.ToString(), | ||
geregistreerd.Data.KboNummer, | ||
geregistreerd.StreamKey!, | ||
Beschrijving: "Registreer inschrijving geslaagd", | ||
geregistreerd.GetHeaderString(MetadataHeaderNames.Tijdstip) | ||
)); | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/AssociationRegistry.Admin.Schema/KboSync/BeheerKboSyncHistoriekGebeurtenisDocument.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,11 @@ | ||
namespace AssociationRegistry.Admin.Schema.KboSync; | ||
|
||
using Marten.Schema; | ||
|
||
public record BeheerKboSyncHistoriekGebeurtenisDocument( | ||
[property: Identity] string Sequence, | ||
string Kbonummer, | ||
string VCode, | ||
string Beschrijving, | ||
string Tijdstip | ||
); |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe return object