Skip to content

Commit

Permalink
feat(prism-agent): Add filter by thid to OpenAPI when fetching records (
Browse files Browse the repository at this point in the history
#436)

Mitigation for ATL-3409
  • Loading branch information
FabioPinheiro authored Mar 13, 2023
1 parent 4122615 commit af01359
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
12 changes: 12 additions & 0 deletions prism-agent/service/api/http/prism-agent-openapi-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ paths:
parameters:
- $ref: "./shared/parameters.yaml#/components/parameters/offset"
- $ref: "./shared/parameters.yaml#/components/parameters/limit"
- name: thid
in: query
description: The thid of a DIDComm communication.
required: false
schema:
type: string
responses:
"200":
description: The list of issue credential records.
Expand Down Expand Up @@ -621,6 +627,12 @@ paths:
parameters:
- $ref: "./shared/parameters.yaml#/components/parameters/offset"
- $ref: "./shared/parameters.yaml#/components/parameters/limit"
- name: thid
in: query
description: The thid of a DIDComm communication.
required: false
schema:
type: string
responses:
"200":
description: The list of proof presentation records.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,21 @@ class IssueCredentialsProtocolApiServiceImpl(
}
}

override def getCredentialRecords(offset: Option[Int], limit: Option[Int])(implicit
override def getCredentialRecords(
offset: Option[Int],
limit: Option[Int],
thid: Option[String],
)(implicit
toEntityMarshallerIssueCredentialRecordCollection: ToEntityMarshaller[IssueCredentialRecordPage],
toEntityMarshallerErrorResponse: ToEntityMarshaller[ErrorResponse]
): Route = {
val result = for {
outcome <- credentialService
records <- credentialService
.getIssueCredentialRecords()
.mapError(HttpServiceError.DomainError[CredentialServiceError].apply)
outcome = thid match
case None => records
case Some(value) => records.filter(_.thid.value == value) // this logic should be moved to the DB
} yield outcome

onZioSuccess(result.mapBoth(_.toOAS, _.map(_.toOAS)).either) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,22 @@ class PresentProofApiServiceImpl(presentationService: PresentationService, conne

}

override def getAllPresentation(offset: Option[Int], limit: Option[Int])(implicit
override def getAllPresentation(
offset: Option[Int],
limit: Option[Int],
thid: Option[String]
)(implicit
toEntityMarshallerPresentationStatusPage: ToEntityMarshaller[PresentationStatusPage],
toEntityMarshallerErrorResponse: ToEntityMarshaller[ErrorResponse]
): Route = {

val result = for {
records <- presentationService
.getPresentationRecords()
.mapError(HttpServiceError.DomainError[PresentationError].apply)
} yield records
outcome = thid match
case None => records
case Some(value) => records.filter(_.thid.value == value) // this logic should be moved to the DB
} yield outcome

onZioSuccess(result.mapBoth(_.toOAS, _.map(_.toOAS)).either) {
case Left(error) => complete(error.status -> error)
Expand Down

0 comments on commit af01359

Please sign in to comment.