Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1107,15 +1107,30 @@ paths:
* `active` - Only active links. (Not expired, no issuance exceeded and not deactivated
* `inactive` - Only deactivated links
* `exceeded` - Expired or maximum issuance exceeded
- in: query
name: page
schema:
type: integer
format: uint
minimum: 1
example: 1
description: Page to fetch. First is one. If omitted, all results will be returned.
- in: query
name: max_results
schema:
type: integer
format: uint
example: 50
default: 50
description: Number of items to fetch on each page. Minimum is 10. Default is 50. No maximum by the moment.

responses:
'200':
description: Link collection
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Link'
$ref: '#/components/schemas/LinksPaginated'
'400':
$ref: '#/components/responses/400'
'404':
Expand Down Expand Up @@ -2067,6 +2082,17 @@ components:
x-omitempty: false
example: https://wallet.privado.id#request_uri=url

LinksPaginated:
type: object
required: [ items, meta ]
properties:
items:
type: array
items:
$ref: '#/components/schemas/Link'
meta:
$ref: '#/components/schemas/PaginatedMetadata'

CredentialSubject:
type: object
x-omitempty: false
Expand Down
30 changes: 29 additions & 1 deletion internal/api/api.gen.go

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

31 changes: 29 additions & 2 deletions internal/api/links.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,39 @@ func (s *Server) GetLinks(ctx context.Context, request GetLinksRequestObject) (G
return GetLinks400JSONResponse{N400JSONResponse{Message: "unknown request type. Allowed: all|active|inactive|exceed"}}, nil
}
}
links, err := s.linkService.GetAll(ctx, *issuerDID, status, request.Params.Query, s.cfg.ServerUrl)

filter := ports.LinksFilter{
Status: status,
Query: request.Params.Query,
Page: request.Params.Page,
}

filter.MaxResults = 10
if request.Params.MaxResults != nil {
if *request.Params.MaxResults <= 0 {
filter.MaxResults = 10
} else {
filter.MaxResults = *request.Params.MaxResults
}
}

links, total, err := s.linkService.GetAll(ctx, *issuerDID, filter, s.cfg.ServerUrl)
if err != nil {
log.Error(ctx, "getting links", "err", err, "req", request)
}

return GetLinks200JSONResponse(getLinkResponses(links)), err
resp := GetLinks200JSONResponse{
Items: getLinkResponses(links),
Meta: PaginatedMetadata{
MaxResults: filter.MaxResults,
Page: 1, // default
Total: total,
},
}
if filter.Page != nil {
resp.Meta.Page = *filter.Page
}
return resp, err
}

// CreateLink - creates a link for issuing a credential
Expand Down
Loading