-
Notifications
You must be signed in to change notification settings - Fork 1
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
e64c189
commit 2a7bcf9
Showing
16 changed files
with
236 additions
and
224 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
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
56 changes: 56 additions & 0 deletions
56
src/Altinn.Profile/Controllers/ContactDetailsInternalController.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,56 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
using Altinn.Profile.Models; | ||
using Altinn.Profile.UseCases; | ||
|
||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Altinn.Profile.Controllers; | ||
|
||
/// <summary> | ||
/// Controller to retrieve the contact details for one or more persons. | ||
/// This controller is intended for internal consumption (e.g., Authorization) requiring neither authenticated user token nor access token authorization. | ||
/// </summary> | ||
[ApiController] | ||
[Consumes("application/json")] | ||
[Produces("application/json")] | ||
[ApiExplorerSettings(IgnoreApi = true)] | ||
[Route("profile/api/v1/internal/contact/details")] | ||
public class ContactDetailsInternalController : ControllerBase | ||
{ | ||
private readonly IContactDetailsRetriever _contactDetailsRetriever; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ContactDetailsInternalController"/> class. | ||
/// </summary> | ||
/// <param name="contactDetailsRetriever">The use case for retrieving the contact details.</param> | ||
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="contactDetailsRetriever"/> is null.</exception> | ||
public ContactDetailsInternalController(IContactDetailsRetriever contactDetailsRetriever) | ||
{ | ||
_contactDetailsRetriever = contactDetailsRetriever ?? throw new ArgumentNullException(nameof(contactDetailsRetriever)); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the contact details for persons based on their national identity numbers. | ||
/// </summary> | ||
/// <param name="request">A collection of national identity numbers.</param> | ||
/// <returns> | ||
/// A task that represents the asynchronous operation, containing a response with persons' contact details. | ||
/// Returns a <see cref="ContactDetailsLookupResult"/> with status 200 OK if successful, | ||
/// 400 Bad Request if the request is invalid, or 404 Not Found if no contact details are found. | ||
/// </returns> | ||
[HttpPost("lookup")] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesResponseType(StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(typeof(ContactDetailsLookupResult), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<ContactDetailsLookupResult>> PostLookup([FromBody] UserContactPointLookup request) | ||
{ | ||
var result = await _contactDetailsRetriever.RetrieveAsync(request); | ||
|
||
return result.Match<ActionResult<ContactDetailsLookupResult>>( | ||
success => Ok(success), | ||
failure => Problem("Unable to retrieve contact details.")); | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
src/Altinn.Profile/Controllers/UserContactDetailsInternalController.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#nullable enable | ||
|
||
using System.Collections.Immutable; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Altinn.Profile.Models; | ||
|
||
/// <summary> | ||
/// Represents the results of a contact details lookup operation. | ||
/// </summary> | ||
public record ContactDetailsLookupResult | ||
{ | ||
/// <summary> | ||
/// Gets a list of contact details that were successfully matched based on the national identity number. | ||
/// </summary> | ||
[JsonPropertyName("matchedContactDetails")] | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public ImmutableList<ContactDetails>? MatchedContactDetails { get; init; } | ||
|
||
/// <summary> | ||
/// Gets a list of national identity numbers that could not be matched with any contact details. | ||
/// </summary> | ||
[JsonPropertyName("unmatchedNationalIdentityNumbers")] | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public ImmutableList<string>? UnmatchedNationalIdentityNumbers { get; init; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ContactDetailsLookupResult"/> record. | ||
/// </summary> | ||
/// <param name="matchedContactDetails">The list of contact details that were successfully matched based on the national identity number.</param> | ||
/// <param name="unmatchedNationalIdentityNumbers">The list of national identity numbers that could not be matched with any contact details.</param> | ||
public ContactDetailsLookupResult( | ||
ImmutableList<ContactDetails> matchedContactDetails, | ||
ImmutableList<string> unmatchedNationalIdentityNumbers) | ||
{ | ||
MatchedContactDetails = matchedContactDetails; | ||
UnmatchedNationalIdentityNumbers = unmatchedNationalIdentityNumbers; | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
src/Altinn.Profile/Models/UserContactDetailsLookupResult.cs
This file was deleted.
Oops, something went wrong.
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.