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: enhance GET credential endpoint with filters #297

Conversation

leandro-cavalcante
Copy link
Contributor

@leandro-cavalcante leandro-cavalcante commented Nov 12, 2024

Internal issuer component enhance get credential endpoint by supporting 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
@evegufy evegufy changed the title feat: Internal issuer component enhance get credential endpoint by su… feat: enhance GET credential endpoint with filters Feb 5, 2025
@evegufy evegufy requested a review from Phil91 February 5, 2025 14:38
Copy link
Contributor

@evegufy evegufy left a comment

Choose a reason for hiding this comment

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

@leandro-cavalcante helm install fails see, this could suggest that the service doesn't start successfully, could you please confirm that that's not the case?

@leandro-cavalcante
Copy link
Contributor Author

@leandro-cavalcante helm install fails see, this could suggest that the service doesn't start successfully, could you please confirm that that's not the case?

I have Sync the PR and now it is working fine.

@leandro-cavalcante
Copy link
Contributor Author

@evegufy This is the correct PR.

@evegufy
Copy link
Contributor

evegufy commented Feb 5, 2025

@leandro-cavalcante there are now 17 unrelated commits show in the PR

Copy link
Contributor

@evegufy evegufy left a comment

Choose a reason for hiding this comment

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

please remove all commits that don't belong to this change

@leandro-cavalcante leandro-cavalcante force-pushed the feature/Enhance-useCaseParticipant-GET-Credential-endpoint-by-supporting-filters branch from f98bfec to 9d3ac69 Compare February 6, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: USER READY
Development

Successfully merging this pull request may close these issues.

4 participants