Skip to content

Commit

Permalink
refactor: align the API for AnonCreds
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Shynbuiev <[email protected]>
  • Loading branch information
yshyn-iohk committed Jan 17, 2025
1 parent 554b6d7 commit 1766228
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ class IssueControllerImpl(
for {
issuingDID <- getIssuingDIDFromAnonCredsProperties(request)
credentialDefinitionGUID <- ZIO
.fromOption(request.anoncredsVcPropertiesV1.map(_.credentialDefinitionId)
.orElse(request.credentialDefinitionId))
.fromOption(
request.anoncredsVcPropertiesV1
.map(_.credentialDefinitionId)
.orElse(request.credentialDefinitionId)
)
.mapError(_ =>
ErrorResponse.badRequest(detail = Some("Missing request parameter: credentialDefinitionId"))
)
Expand Down Expand Up @@ -220,6 +223,9 @@ class IssueControllerImpl(
claims <- ZIO
.fromOption(request.anoncredsVcPropertiesV1.map(_.claims).orElse(request.claims))
.orElseFail(ErrorResponse.badRequest(detail = Some("Missing request parameter: claims")))
validityPeriod = request.anoncredsVcPropertiesV1
.flatMap(_.validityPeriod)
.orElse(request.validityPeriod)
record <- credentialService
.createAnonCredsIssueCredentialRecord(
pairwiseIssuerDID = offerContext.pairwiseIssuerDID,
Expand All @@ -228,7 +234,7 @@ class IssueControllerImpl(
credentialDefinitionGUID = credentialDefinitionGUID,
credentialDefinitionId = credentialDefinitionId,
claims = claims,
validityPeriod = request.validityPeriod,
validityPeriod = validityPeriod,
automaticIssuance = request.automaticIssuance.orElse(Some(true)),
goalCode = offerContext.goalCode,
goal = offerContext.goal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ case class AnonCredsVCPropertiesV1(
@description(annotations.issuingDID.description)
@encodedExample(annotations.issuingDID.example)
issuingDID: String,
@description(AnonCredsVCPropertiesV1.annotations.schemaId.description)
@encodedExample(AnonCredsVCPropertiesV1.annotations.schemaId.example)
schemaId: String,
@description(AnonCredsVCPropertiesV1.annotations.credentialDefinitionId.description)
@encodedExample(AnonCredsVCPropertiesV1.annotations.credentialDefinitionId.example)
credentialDefinitionId: UUID,
@description(AnonCredsVCPropertiesV1.annotations.claims.description)
@encodedExample(AnonCredsVCPropertiesV1.annotations.claims.example)
claims: zio.json.ast.Json
claims: zio.json.ast.Json,
@description(annotations.validityPeriod.description)
@encodedExample(annotations.validityPeriod.example)
validityPeriod: Option[Double]
)

object AnonCredsVCPropertiesV1 {
Expand All @@ -209,15 +209,6 @@ object AnonCredsVCPropertiesV1 {
given decoder: JsonDecoder[AnonCredsVCPropertiesV1] = DeriveJsonDecoder.gen

object annotations {
object schemaId
extends Annotation[String](
description = """
|The URL or DIDURL pointing to the AnonCreds schema that will be used for this offer.
|When dereferenced, the returned content should be a JSON schema compliant with the '[AnonCreds v1.0 schema](https://hyperledger.github.io/anoncreds-spec/#term:schema)' version of the specification.
|""".stripMargin,
example =
"https://agent-host.com/cloud-agent/schema-registry/schemas/d9569cec-c81e-4779-aa86-0d5994d82676/schema"
)
object credentialDefinitionId
extends Annotation[UUID](
description = """
Expand Down

0 comments on commit 1766228

Please sign in to comment.