Skip to content

Commit

Permalink
Merge pull request #872 from 0xPolygonID/IN-128-add-display-method-fo…
Browse files Browse the repository at this point in the history
…r-schemas

chore: add display method id to schemas
  • Loading branch information
martinsaporiti authored Dec 31, 2024
2 parents d51045c + 1d2e0e1 commit 96f8186
Show file tree
Hide file tree
Showing 43 changed files with 2,278 additions and 1,572 deletions.
3 changes: 2 additions & 1 deletion .env-ui.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ ISSUER_UI_WARNING_MESSAGE=
ISSUER_UI_IPFS_GATEWAY_URL=https://ipfs-proxy-cache.privado.id
ISSUER_UI_SCHEMA_EXPLORER_AND_BUILDER_URL=https://tools.privado.id
ISSUER_UI_DISPLAY_METHOD_BUILDER_URL=https://display-method-dev.privado.id
ISSUER_UI_INSECURE=false
ISSUER_UI_INSECURE=false
ISSUER_UI_BASE_URL=/
45 changes: 45 additions & 0 deletions api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,43 @@ paths:
'500':
$ref: '#/components/responses/500'

patch:
summary: Update Schema
operationId: UpdateSchema
description: Update a specific schema for the provided identity.
security:
- basicAuth: [ ]
tags:
- Schemas
parameters:
- $ref: '#/components/parameters/pathIdentifier'
- $ref: '#/components/parameters/id'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
displayMethodID:
type: string
x-go-type: uuid.UUID
x-omitempty: false

responses:
'200':
description: Schema information
content:
application/json:
schema:
$ref: '#/components/schemas/GenericMessage'
'400':
$ref: '#/components/responses/400'
'404':
$ref: '#/components/responses/404'
'500':
$ref: '#/components/responses/500'


# Links
/v2/identities/{identifier}/credentials/links:
Expand Down Expand Up @@ -2265,6 +2302,10 @@ components:
version:
type: string
example: "1.0.0"
displayMethodID:
type: string
x-go-type: uuid.UUID
x-omitempty: false

Schema:
type: object
Expand Down Expand Up @@ -2315,6 +2356,10 @@ components:
type: string
x-omitempty: false
example: "1.0.0"
displayMethodID:
type: string
x-go-type: uuid.UUID
x-omitempty: false

# display method
DisplayMethod:
Expand Down
4 changes: 2 additions & 2 deletions cmd/platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ func main() {
identityService := services.NewIdentity(keyStore, identityRepository, mtRepository, identityStateRepository, mtService, qrService, claimsRepository, revocationRepository, connectionsRepository, storage, verifier, sessionRepository, ps, *networkResolver, rhsFactory, revocationStatusResolver, keyRepository)
claimsService := services.NewClaim(claimsRepository, identityService, qrService, mtService, identityStateRepository, schemaLoader, storage, cfg.ServerUrl, ps, cfg.IPFS.GatewayURL, revocationStatusResolver, mediaTypeManager, cfg.UniversalLinks)
proofService := services.NewProver(circuitsLoaderService)
schemaService := services.NewSchema(schemaRepository, schemaLoader)
displayMethodService := services.NewDisplayMethod(repositories.NewDisplayMethod(*storage))
schemaService := services.NewSchema(schemaRepository, schemaLoader, displayMethodService)
linkService := services.NewLinkService(storage, claimsService, qrService, claimsRepository, linkRepository, schemaRepository, schemaLoader, sessionRepository, ps, identityService, *networkResolver, cfg.UniversalLinks)
paymentService := services.NewPaymentService(paymentsRepo, *networkResolver, schemaService, paymentSettings, keyStore)
displayMethodService := services.NewDisplayMethod(repositories.NewDisplayMethod(*storage))
keyService := services.NewKey(keyStore, claimsService, keyRepository)
transactionService, err := gateways.NewTransaction(*networkResolver)
if err != nil {
Expand Down
175 changes: 160 additions & 15 deletions internal/api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/api/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ func TestServer_GetCredentials(t *testing.T) {
require.NoError(t, err)
require.NoError(t, claimsService.Revoke(ctx, *id, uint64(revoked.RevNonce), "because I can"))

iReq := ports.NewImportSchemaRequest(schemaURL, typeC, common.ToPointer("someTitle"), uuid.NewString(), common.ToPointer("someDescription"))
iReq := ports.NewImportSchemaRequest(schemaURL, typeC, common.ToPointer("someTitle"), uuid.NewString(), common.ToPointer("someDescription"), nil)
_, err = server.schemaService.ImportSchema(ctx, *did, iReq)
require.NoError(t, err)

Expand Down
10 changes: 8 additions & 2 deletions internal/api/display_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *Server) CreateDisplayMethod(ctx context.Context, request CreateDisplayM
id, err := s.displayMethodService.Save(ctx, *identityDID, request.Body.Name, request.Body.Url, request.Body.Type)
if err != nil {
log.Error(ctx, "Error saving display method", "err", err)
if errors.Is(err, repositories.DisplayMethodDuplicateNameError) {
if errors.Is(err, repositories.DisplayMethodDuplicateNameErr) {
return CreateDisplayMethod400JSONResponse{N400JSONResponse{Message: "name already exist"}}, nil
}
return CreateDisplayMethod500JSONResponse{N500JSONResponse{Message: "Error saving display method"}}, nil
Expand Down Expand Up @@ -128,7 +128,7 @@ func (s *Server) UpdateDisplayMethod(ctx context.Context, request UpdateDisplayM
if errors.Is(err, repositories.DisplayMethodNotFoundErr) {
return UpdateDisplayMethod404JSONResponse{N404JSONResponse{Message: "Display method not found"}}, nil
}
if errors.Is(err, repositories.DisplayMethodDuplicateNameError) {
if errors.Is(err, repositories.DisplayMethodDuplicateNameErr) {
return UpdateDisplayMethod400JSONResponse{N400JSONResponse{Message: "Duplicated name display method"}}, nil
}
return UpdateDisplayMethod500JSONResponse{N500JSONResponse{Message: "Error updating display method"}}, nil
Expand Down Expand Up @@ -156,6 +156,12 @@ func (s *Server) DeleteDisplayMethod(ctx context.Context, request DeleteDisplayM
log.Error(ctx, "Cannot delete default display method", "err", err)
return DeleteDisplayMethod400JSONResponse{N400JSONResponse{Message: "Cannot delete default display method"}}, nil
}

if errors.Is(err, repositories.DisplayMethodAssignedErr) {
log.Error(ctx, "Cannot delete display method assigned", "err", err)
return DeleteDisplayMethod400JSONResponse{N400JSONResponse{Message: "Cannot delete display method assigned"}}, nil
}

return DeleteDisplayMethod500JSONResponse{N500JSONResponse{Message: "Error deleting display method"}}, nil
}

Expand Down
Loading

0 comments on commit 96f8186

Please sign in to comment.