4
4
# pylint: disable=too-few-public-methods
5
5
6
6
from marshmallow import fields
7
+ import json
7
8
8
9
from aries_cloudagent .config .injection_context import InjectionContext
9
10
from aries_cloudagent .core .protocol_registry import ProtocolRegistry
11
+ from aries_cloudagent .holder .base import BaseHolder
10
12
from aries_cloudagent .messaging .base_handler import BaseHandler , BaseResponder , RequestContext
11
13
from aries_cloudagent .protocols .issue_credential .v1_0 .routes import (
12
14
V10CredentialExchangeListResultSchema ,
36
38
37
39
from aries_cloudagent .connections .models .connection_record import ConnectionRecord
38
40
from aries_cloudagent .storage .error import StorageNotFoundError
39
- from aries_cloudagent .protocols .problem_report .message import ProblemReport
41
+ from aries_cloudagent .protocols .problem_report .v1_0 . message import ProblemReport
40
42
41
43
from .util import generate_model_schema , admin_only
42
44
PROTOCOL = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/admin-holder/0.1'
@@ -236,10 +238,10 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
236
238
name = 'CredList' ,
237
239
handler = 'acapy_plugin_toolbox.util.PassHandler' ,
238
240
msg_type = CREDENTIALS_LIST ,
239
- schema = V10CredentialExchangeListResultSchema
240
- # schema={
241
- # 'results': fields.List(fields.Dict())
242
- # }
241
+ # schema=V10CredentialExchangeListResultSchema
242
+ schema = {
243
+ 'results' : fields .List (fields .Dict ())
244
+ }
243
245
)
244
246
245
247
@@ -255,17 +257,31 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
255
257
# cred_list = CredList(results=credentials)
256
258
# await responder.send_reply(cred_list)
257
259
258
- post_filter = dict (
259
- filter (lambda item : item [1 ] is not None , {
260
- # 'state': V10CredentialExchange.STATE_CREDENTIAL_RECEIVED,
261
- 'role' : V10CredentialExchange .ROLE_HOLDER ,
262
- 'connection_id' : context .message .connection_id ,
263
- 'credential_definition_id' : context .message .credential_definition_id ,
264
- 'schema_id' : context .message .schema_id
265
- }.items ())
266
- )
267
- records = await V10CredentialExchange .query (context , {}, post_filter )
268
- cred_list = CredList (results = records )
260
+ start = 0 #request.query.get("start")
261
+ count = 10 #request.query.get("count")
262
+
263
+ # url encoded json wql
264
+ encoded_wql = "{}" #request.query.get("wql") or "{}"
265
+ wql = json .loads (encoded_wql )
266
+
267
+ # defaults
268
+ #start = int(start) if isinstance(start, str) else 0
269
+ #count = int(count) if isinstance(count, str) else 10
270
+
271
+ holder : BaseHolder = await context .inject (BaseHolder )
272
+ credentials = await holder .get_credentials (start , count , wql )
273
+
274
+ # post_filter_positive = dict(
275
+ # filter(lambda item: item[1] is not None, {
276
+ # # 'state': V10CredentialExchange.STATE_CREDENTIAL_RECEIVED,
277
+ # #'role': V10CredentialExchange.ROLE_HOLDER,
278
+ # 'connection_id': context.message.connection_id,
279
+ # 'credential_definition_id': context.message.credential_definition_id,
280
+ # 'schema_id': context.message.schema_id
281
+ # }.items())
282
+ # )
283
+ # records = await V10CredentialExchange.query(context, {}, post_filter_positive)
284
+ cred_list = CredList (results = credentials )
269
285
await responder .send_reply (cred_list )
270
286
271
287
@@ -297,14 +313,14 @@ class PresGetListHandler(BaseHandler):
297
313
async def handle (self , context : RequestContext , responder : BaseResponder ):
298
314
"""Handle received get cred list request."""
299
315
300
- post_filter = dict (
316
+ post_filter_positive = dict (
301
317
filter (lambda item : item [1 ] is not None , {
302
318
# 'state': V10PresentialExchange.STATE_CREDENTIAL_RECEIVED,
303
319
'role' : V10PresentationExchange .ROLE_PROVER ,
304
320
'connection_id' : context .message .connection_id ,
305
321
'verified' : context .message .verified ,
306
322
}.items ())
307
323
)
308
- records = await V10PresentationExchange .query (context , {}, post_filter )
324
+ records = await V10PresentationExchange .query (context , {}, post_filter_positive )
309
325
cred_list = PresList (results = records )
310
326
await responder .send_reply (cred_list )
0 commit comments