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

Add GET method for Issuer /credentials and /offers endpoints #118

Closed
3 tasks done
nanderstabel opened this issue Sep 17, 2024 · 0 comments
Closed
3 tasks done

Add GET method for Issuer /credentials and /offers endpoints #118

nanderstabel opened this issue Sep 17, 2024 · 0 comments
Assignees
Labels
Added A new feature that requires a minor release.

Comments

@nanderstabel
Copy link
Collaborator

nanderstabel commented Sep 17, 2024

Description

This will ensure that all Credentials and Offers can be queried.

A ListAllQuery need to be added to agent_store similar to the way it is implemented in fn holder_state in both postgres.rs and in_memory.rs.
The endpoints handlers need to be added to agent_api_rest

The following can be copied into fn issuer_state (including the lines that initialize the all_credentials and all_offers View Repositories):

    // Create custom-queries for the offer aggregate.
    let all_credentials_query = ListAllQuery::new(all_credentials.clone(), "all_credentials");
    let all_offers_query = ListAllQuery::new(all_offers.clone(), "all_offers");

Important detail is that in order for the view_id's not to overlap with each other those current three lines in fn holder_state need to be changed to:

    // Create custom-queries for the offer aggregate.
    let all_holder_credentials_query = ListAllQuery::new(all_credentials.clone(), "all_holder_credentials");
    let all_received_offers_query = ListAllQuery::new(all_offers.clone(), "all_received_offers");

This means that all other code occurrences of all_credentials and all_offers need to be updated as well (including inside the init.sql file):
all_credentials --> all_holder_credentials
all_offers --> all_received_offers

The View Repositories are added to agent_holder::state::ViewRepositories in fn holder_state. The exact same thing needs to be implemented in fn issuer_state. This means that agent_issuer::state::ViewRepositories needs to be updated to include the all_credentials and all_offers View Repositories the same way it is done in agent_holder::state::ViewRepositories:

type Queries = ViewRepositories<
    dyn ViewRepository<CredentialView, Credential>,
    dyn ViewRepository<AllCredentialsView, Credential>, // <-- this
    dyn ViewRepository<OfferView, Offer>,
    dyn ViewRepository<AllOffersView, Offer>, // <-- this
>;

pub struct ViewRepositories<C1, C2, O1, O2>
where
    C1: ViewRepository<CredentialView, Credential> + ?Sized,
    C2: ViewRepository<AllCredentialsView, Credential> + ?Sized, // <-- this
    O1: ViewRepository<OfferView, Offer> + ?Sized,
    O2: ViewRepository<AllOffersView, Offer> + ?Sized, // <-- this
{
    pub credential: Arc<C1>,
    pub all_credentials: Arc<C2>, // <-- this
    pub offer: Arc<O1>,
    pub all_offers: Arc<O2>, // <-- this
}

impl Clone for Queries {
    fn clone(&self) -> Self {
        ViewRepositories {
            credential: self.credential.clone(),
            all_credentials: self.all_credentials.clone(), // <-- this
            offer: self.offer.clone(),
            all_offers: self.all_offers.clone(), // <-- this
        }
    }
}

This also means that AllCredentialsView and AllOffersView can be copy-pasted from the agent_holder crate. In the same fashion as earlier mentioned, the following occurrences should be renamed:

  • AllCredentialsView --> AllHolderCredentialsView
  • AllOffersView --> AllReceivedOffersView

Motivation

Improves UniCore's utility

Resources

n/a

To-do List

  • Add AllCredentialsView and AllOffersView
  • Add GET method for /credentials
  • Add GET method for /offers
@nanderstabel nanderstabel added the Added A new feature that requires a minor release. label Sep 17, 2024
@Oran-Dan Oran-Dan self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added A new feature that requires a minor release.
Projects
None yet
Development

No branches or pull requests

2 participants