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

feat: Internal issuer component enhance get credential endpoint by su… #297

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

leandro-cavalcante
Copy link
Contributor

…pporting filters

Description

The purpose of this feature is to enhance the functionality of the existing GET /api/issuer/useCaseParticipation endpoint in the Issuer Component. The enhancement involves the ability to filter the returned list of use case participations by the status of the credentials (Active, Expired, or All).

Why

Instead of always returning all use case credentials it gives the customer the power of retrieving it by status.

Issue

NA

Checklist

Please delete options that are not relevant.

  • I have followed the contributing guidelines
  • I have created and linked IP issues or requested their creation by a committer
  • I have performed a self-review of my own code
  • I have successfully tested my changes locally
  • I have added tests that prove my changes work
  • I have checked that new and existing tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas
  • I have added copyright and license headers, footers (for .md files) or files (for images)

@MaximilianHauer
Copy link
Contributor

business perspective sounds reasonable .

@@ -0,0 +1,8 @@
namespace Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a licence header

@@ -26,7 +26,7 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.BusinessLogic;

public interface IIssuerBusinessLogic
{
IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync();
IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync(string? status);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly user StatusType?

Suggested change
IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync(string? status);
IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync(StatusType? status);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the StatusType was not used because the error messages we have to throw to the user. They are customized and with the use of the object it self it would not be possible.

Comment on lines +88 to +98
public IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync(string? status)
{
StatusType? statusTypeResult = null;
if (!string.IsNullOrEmpty(status))
{
if (!(Enum.TryParse<StatusType>(status, ignoreCase: true, out var statusType) || !Enum.IsDefined(typeof(StatusType), statusType)))
{
throw new ArgumentException($"Status value {status} is not valid; please use Active, Expired or All");
}
statusTypeResult = statusType;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly use StatusType, than the conversion isn't needed

Suggested change
public IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync(string? status)
{
StatusType? statusTypeResult = null;
if (!string.IsNullOrEmpty(status))
{
if (!(Enum.TryParse<StatusType>(status, ignoreCase: true, out var statusType) || !Enum.IsDefined(typeof(StatusType), statusType)))
{
throw new ArgumentException($"Status value {status} is not valid; please use Active, Expired or All");
}
statusTypeResult = statusType;
}
public IAsyncEnumerable<UseCaseParticipationData> GetUseCaseParticipationAsync(StatusType? status)
{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the same. When I use the type object I cannot have a customized message. At least I could not find a way to do that. I would be grateful to have a support here

@@ -42,16 +42,18 @@ public static RouteGroupBuilder MapIssuerApi(this RouteGroupBuilder group)
{
var issuer = group.MapGroup("/issuer");

issuer.MapGet("useCaseParticipation", (IIssuerBusinessLogic logic) => logic.GetUseCaseParticipationAsync())
issuer.MapGet("useCaseParticipation", (IIssuerBusinessLogic logic,
[FromQuery(Name = "status")] string? status) => logic.GetUseCaseParticipationAsync(status))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be changed to StatusType as well

Suggested change
[FromQuery(Name = "status")] string? status) => logic.GetUseCaseParticipationAsync(status))
[FromQuery(Name = "status")] StatusType? status) => logic.GetUseCaseParticipationAsync(status))

Copy link
Contributor Author

@leandro-cavalcante leandro-cavalcante Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here, it is just to have a customized error message.

@MaximilianHauer MaximilianHauer added this to the Release 25.03 milestone Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: IN PROGRESS
Development

Successfully merging this pull request may close these issues.

3 participants