hyperledger-archives / aries-framework-dotnet

Aries Framework .NET for building multiplatform SSI services
https://wiki.hyperledger.org/display/aries
Apache License 2.0
84 stars 74 forks source link

API - Get credential by Id #132

Closed RinkalBhojani closed 4 years ago

RinkalBhojani commented 4 years ago

@tmarkovski @StevenTCramer

For new API support, existing implementation of getting single credential record for a given credentialId is as shown below. Existing implementation: {

  IAgentContext agentContext = await AgentProvider.GetContextAsync();
  List<CredentialRecord> credentialRecords = await CredentialService.ListAsync(agentContext);
  CredentialRecord credentialRecord =
    credentialRecords
      .FirstOrDefault(aCredentialRecord => aCredentialRecord.CredentialId == aGetCredentialRequest.CredentialId);

  var response = new GetCredentialResponse(aGetCredentialRequest.CorrelationId, credentialRecord);
  return response;

} There already exists a method which directly fetches the single record for a given credentialId. Can we not use GetAsync() method instead of ListAsync() method?

Proposed implementation: {

  IAgentContext agentContext = await AgentProvider.GetContextAsync();
  CredentialRecord credentialRecord = await CredentialService.GetAsync(agentContext, aGetCredentialRequest.CredentialId);
  var response = new GetCredentialResponse(aGetCredentialRequest.CorrelationId, credentialRecord);
  return response;

} I have implemented and tested it. Below is the link for the above changes. Kindly verify and assist so that we can merge this change if required and valid. https://github.com/RinkalBhojani/aries-framework-dotnet/commit/c8446eb3add2e9e6974d72c59f1404fb3d9782b2

StevenTCramer commented 4 years ago

@RinkalBhojani my first impression is you are correct. If you would like to do a PR that would be great.