Module mydata_did.patched_protocols.issue_credential.v1_0.messages.credential_request
A credential request content message.
Expand source code
"""A credential request content message."""
from typing import Sequence
from marshmallow import EXCLUDE, fields
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from aries_cloudagent.messaging.decorators.attach_decorator import (
AttachDecorator,
AttachDecoratorSchema,
)
from ..message_types import ATTACH_DECO_IDS, CREDENTIAL_REQUEST, PROTOCOL_PACKAGE
from .....v1_0.decorators.patched_decorator_set import PatchedDecoratorSet
HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers."
"credential_request_handler.CredentialRequestHandler"
)
class CredentialRequest(AgentMessage):
"""Class representing a credential request."""
class Meta:
"""CredentialRequest metadata."""
handler_class = HANDLER_CLASS
schema_class = "CredentialRequestSchema"
message_type = CREDENTIAL_REQUEST
def __init__(
self,
_id: str = None,
*,
comment: str = None,
requests_attach: Sequence[AttachDecorator] = None,
**kwargs,
):
"""
Initialize credential request object.
Args:
requests_attach: requests attachments
comment: optional comment
"""
super().__init__(_id=_id, _decorators=PatchedDecoratorSet(), **kwargs)
self.comment = comment
self.requests_attach = list(requests_attach) if requests_attach else []
def indy_cred_req(self, index: int = 0):
"""
Retrieve and decode indy credential request from attachment.
Args:
index: ordinal in attachment list to decode and return
(typically, list has length 1)
"""
return self.requests_attach[index].indy_dict
@classmethod
def wrap_indy_cred_req(cls, indy_cred_req: dict) -> AttachDecorator:
"""Convert an indy credential request to an attachment decorator."""
return AttachDecorator.from_indy_dict(
indy_dict=indy_cred_req, ident=ATTACH_DECO_IDS[CREDENTIAL_REQUEST]
)
class CredentialRequestSchema(AgentMessageSchema):
"""Credential request schema."""
class Meta:
"""Credential request schema metadata."""
model_class = CredentialRequest
unknown = EXCLUDE
comment = fields.Str(
description="Human-readable comment", required=False, allow_none=True
)
requests_attach = fields.Nested(
AttachDecoratorSchema, required=True, many=True, data_key="requests~attach"
)
Classes
class CredentialRequest (*, comment: str = None, requests_attach: Sequence[aries_cloudagent.messaging.decorators.attach_decorator.AttachDecorator] = None, **kwargs)
-
Class representing a credential request.
Initialize credential request object.
Args
requests_attach
- requests attachments
comment
- optional comment
Expand source code
class CredentialRequest(AgentMessage): """Class representing a credential request.""" class Meta: """CredentialRequest metadata.""" handler_class = HANDLER_CLASS schema_class = "CredentialRequestSchema" message_type = CREDENTIAL_REQUEST def __init__( self, _id: str = None, *, comment: str = None, requests_attach: Sequence[AttachDecorator] = None, **kwargs, ): """ Initialize credential request object. Args: requests_attach: requests attachments comment: optional comment """ super().__init__(_id=_id, _decorators=PatchedDecoratorSet(), **kwargs) self.comment = comment self.requests_attach = list(requests_attach) if requests_attach else [] def indy_cred_req(self, index: int = 0): """ Retrieve and decode indy credential request from attachment. Args: index: ordinal in attachment list to decode and return (typically, list has length 1) """ return self.requests_attach[index].indy_dict @classmethod def wrap_indy_cred_req(cls, indy_cred_req: dict) -> AttachDecorator: """Convert an indy credential request to an attachment decorator.""" return AttachDecorator.from_indy_dict( indy_dict=indy_cred_req, ident=ATTACH_DECO_IDS[CREDENTIAL_REQUEST] )
Ancestors
- aries_cloudagent.messaging.agent_message.AgentMessage
- aries_cloudagent.messaging.models.base.BaseModel
- abc.ABC
Class variables
var Meta
-
CredentialRequest metadata.
Static methods
def wrap_indy_cred_req(indy_cred_req: dict) ‑> aries_cloudagent.messaging.decorators.attach_decorator.AttachDecorator
-
Convert an indy credential request to an attachment decorator.
Expand source code
@classmethod def wrap_indy_cred_req(cls, indy_cred_req: dict) -> AttachDecorator: """Convert an indy credential request to an attachment decorator.""" return AttachDecorator.from_indy_dict( indy_dict=indy_cred_req, ident=ATTACH_DECO_IDS[CREDENTIAL_REQUEST] )
Methods
def indy_cred_req(self, index: int = 0)
-
Retrieve and decode indy credential request from attachment.
Args
index
- ordinal in attachment list to decode and return (typically, list has length 1)
Expand source code
def indy_cred_req(self, index: int = 0): """ Retrieve and decode indy credential request from attachment. Args: index: ordinal in attachment list to decode and return (typically, list has length 1) """ return self.requests_attach[index].indy_dict
class CredentialRequestSchema (*args, **kwargs)
-
Credential request schema.
Initialize an instance of AgentMessageSchema.
Raises
TypeError
- If Meta.model_class has not been set
Expand source code
class CredentialRequestSchema(AgentMessageSchema): """Credential request schema.""" class Meta: """Credential request schema metadata.""" model_class = CredentialRequest unknown = EXCLUDE comment = fields.Str( description="Human-readable comment", required=False, allow_none=True ) requests_attach = fields.Nested( AttachDecoratorSchema, required=True, many=True, data_key="requests~attach" )
Ancestors
- aries_cloudagent.messaging.agent_message.AgentMessageSchema
- aries_cloudagent.messaging.models.base.BaseModelSchema
- marshmallow.schema.Schema
- marshmallow.base.SchemaABC
Class variables
var Meta
-
Credential request schema metadata.
var opts