Skip to content

Commit

Permalink
feat(address): add parameters to search
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Dec 17, 2024
1 parent 7044467 commit be8547d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ nuget Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Oslo 4.14.0
nuget Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.Abstractions 4.14.0 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.BuildingRegistry.Api.Oslo 4.19.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.BuildingRegistry.Api.BackOffice.Abstractions 4.19.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo 4.27.2 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.27.2 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo 4.29.4 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions 4.29.4 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Oslo 5.8.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions 5.8.1 copy_content_to_output_dir: always
nuget Be.Vlaanderen.Basisregisters.RoadRegistry.BackOffice 4.7.0 copy_content_to_output_dir: always
Expand Down
4 changes: 2 additions & 2 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ NUGET
System.Security.Cryptography.ProtectedData (>= 4.7)
System.Text.Json (>= 4.7.2)
System.Threading.Tasks.Extensions (>= 4.5.4)
Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions (4.27.2) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.AddressRegistry.Api.BackOffice.Abstractions (4.29.4) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.Api (>= 23.1)
MediatR.Contracts (>= 2.0.1)
Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo (4.27.2) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.AddressRegistry.Api.Oslo (4.29.4) - copy_content_to_output_dir: always
Be.Vlaanderen.Basisregisters.GrAr.Legacy (>= 21.14.1)
MediatR.Contracts (>= 2.0.1)
Be.Vlaanderen.Basisregisters.AggregateSource (9.0.1)
Expand Down
39 changes: 31 additions & 8 deletions src/Public.Api/Address/Oslo/AddressController-Search.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Public.Api.Address.Oslo
{
using System;
using System.Threading;
using System.Threading.Tasks;
using AddressRegistry.Api.Oslo.Address.Search;
Expand Down Expand Up @@ -27,12 +28,16 @@ public partial class AddressOsloController
/// Zoeken naar adressen of straatnamen via een query.
/// </summary>
/// <param name="query">De zoek query.</param>
/// <param name="municipalityOrPostalName">Limiteer de zoek query in een te zoeken gemeente- of postnaam (optioneel).</param>
/// <param name="municipalityName">Filter op de gemeentenaam van de zoek query (exact) (optioneel).</param>
/// <param name="nisCode">Filter op de NIS-code van de zoek query (exact) (optioneel).</param>
/// <param name="limit">Aantal instanties dat teruggegeven wordt. Maximaal kunnen er 50 worden teruggegeven. Wanneer limit niet wordt meegegeven dan default 10 instanties (optioneel).</param>
/// <param name="status">
/// Filter op de status van het adres of de straatnaam (exact) (optioneel). \
/// `"voorgesteld"` `"inGebruik"` `"gehistoreerd"` `"afgekeurd"`
/// </param>
/// <param name="resultType">
/// Specifieer de gewenste resultaten (exact) (optioneel). \
/// `"adressen"` `"straatnamen"`</param>
/// <param name="searchAddressesToggle"></param>
/// <param name="actionContextAccessor"></param>
/// <param name="responseOptions"></param>
Expand Down Expand Up @@ -62,9 +67,11 @@ public partial class AddressOsloController
[HttpGet("adressen/zoeken", Name = nameof(SearchAddresses))]
public async Task<IActionResult> SearchAddresses(
[FromQuery(Name = "q")] string? query,
[FromQuery(Name="gemeenteOfPostNaam")] string? municipalityOrPostalName,
[FromQuery(Name="gemeenteNaam")] string? municipalityName,
[FromQuery(Name="niscode")] string? nisCode,
[FromQuery] int? limit,
[FromQuery] string? status,
[FromQuery(Name="resultaatType")] string? resultType,
[FromServices] SearchAddressesToggle searchAddressesToggle,
[FromServices] IActionContextAccessor actionContextAccessor,
[FromServices] IOptions<AddressOptionsV2> responseOptions,
Expand All @@ -81,8 +88,10 @@ public async Task<IActionResult> SearchAddresses(
RestRequest BackendRequest() => CreateBackendListRequest(
limit,
query,
municipalityOrPostalName,
status);
municipalityName,
nisCode,
status,
resultType);

var value = await GetFromBackendAsync(
contentFormat.ContentType,
Expand All @@ -96,14 +105,28 @@ RestRequest BackendRequest() => CreateBackendListRequest(
private static RestRequest CreateBackendListRequest(
int? limit,
string? query,
string? municipalityOrPostalName,
string? status)
string? municipalityName,
string? nisCode,
string? status,
string? resultType)
{
ResultType? resultTypeParsed = null;
if (string.Equals(resultType, "adressen", StringComparison.OrdinalIgnoreCase))
{
resultTypeParsed = ResultType.Address;
}
else if (string.Equals(resultType, "straatnamen", StringComparison.OrdinalIgnoreCase))
{
resultTypeParsed = ResultType.StreetName;
}

var filter = new AddressSearchFilter
{
Query = query,
MunicipalityOrPostalName = municipalityOrPostalName,
Status = status
MunicipalityName = municipalityName,
NisCode = nisCode,
Status = status,
ResultType = resultTypeParsed
};

return new RestRequest("adressen/zoeken")
Expand Down

0 comments on commit be8547d

Please sign in to comment.