Module mydata_did.patched_protocols.issue_credential.v1_0.messages.credential_issue
A credential content message.
Expand source code
"""A credential 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_ISSUE, PROTOCOL_PACKAGE
from .....v1_0.decorators.patched_decorator_set import PatchedDecoratorSet
HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.credential_issue_handler.CredentialIssueHandler"
)
class CredentialIssue(AgentMessage):
"""Class representing a credential."""
class Meta:
"""Credential metadata."""
handler_class = HANDLER_CLASS
schema_class = "CredentialIssueSchema"
message_type = CREDENTIAL_ISSUE
def __init__(
self,
_id: str = None,
*,
comment: str = None,
credentials_attach: Sequence[AttachDecorator] = None,
**kwargs,
):
"""
Initialize credential issue object.
Args:
comment: optional comment
credentials_attach: credentials attachments
"""
super().__init__(_id=_id, _decorators=PatchedDecoratorSet(), **kwargs)
self.comment = comment
self.credentials_attach = list(credentials_attach) if credentials_attach else []
def indy_credential(self, index: int = 0):
"""
Retrieve and decode indy credential from attachment.
Args:
index: ordinal in attachment list to decode and return
(typically, list has length 1)
"""
return self.credentials_attach[index].indy_dict
@classmethod
def wrap_indy_credential(cls, indy_cred: dict) -> AttachDecorator:
"""Convert an indy credential offer to an attachment decorator."""
return AttachDecorator.from_indy_dict(
indy_dict=indy_cred, ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE]
)
class CredentialIssueSchema(AgentMessageSchema):
"""Credential schema."""
class Meta:
"""Credential schema metadata."""
model_class = CredentialIssue
unknown = EXCLUDE
comment = fields.Str(
description="Human-readable comment", required=False, allow_none=True
)
credentials_attach = fields.Nested(
AttachDecoratorSchema, required=True, many=True, data_key="credentials~attach"
)
Classes
class CredentialIssue (*, comment: str = None, credentials_attach: Sequence[aries_cloudagent.messaging.decorators.attach_decorator.AttachDecorator] = None, **kwargs)
-
Class representing a credential.
Initialize credential issue object.
Args
comment
- optional comment
credentials_attach
- credentials attachments
Expand source code
class CredentialIssue(AgentMessage): """Class representing a credential.""" class Meta: """Credential metadata.""" handler_class = HANDLER_CLASS schema_class = "CredentialIssueSchema" message_type = CREDENTIAL_ISSUE def __init__( self, _id: str = None, *, comment: str = None, credentials_attach: Sequence[AttachDecorator] = None, **kwargs, ): """ Initialize credential issue object. Args: comment: optional comment credentials_attach: credentials attachments """ super().__init__(_id=_id, _decorators=PatchedDecoratorSet(), **kwargs) self.comment = comment self.credentials_attach = list(credentials_attach) if credentials_attach else [] def indy_credential(self, index: int = 0): """ Retrieve and decode indy credential from attachment. Args: index: ordinal in attachment list to decode and return (typically, list has length 1) """ return self.credentials_attach[index].indy_dict @classmethod def wrap_indy_credential(cls, indy_cred: dict) -> AttachDecorator: """Convert an indy credential offer to an attachment decorator.""" return AttachDecorator.from_indy_dict( indy_dict=indy_cred, ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE] )
Ancestors
- aries_cloudagent.messaging.agent_message.AgentMessage
- aries_cloudagent.messaging.models.base.BaseModel
- abc.ABC
Class variables
var Meta
-
Credential metadata.
Static methods
def wrap_indy_credential(indy_cred: dict) ‑> aries_cloudagent.messaging.decorators.attach_decorator.AttachDecorator
-
Convert an indy credential offer to an attachment decorator.
Expand source code
@classmethod def wrap_indy_credential(cls, indy_cred: dict) -> AttachDecorator: """Convert an indy credential offer to an attachment decorator.""" return AttachDecorator.from_indy_dict( indy_dict=indy_cred, ident=ATTACH_DECO_IDS[CREDENTIAL_ISSUE] )
Methods
def indy_credential(self, index: int = 0)
-
Retrieve and decode indy credential from attachment.
Args
index
- ordinal in attachment list to decode and return (typically, list has length 1)
Expand source code
def indy_credential(self, index: int = 0): """ Retrieve and decode indy credential from attachment. Args: index: ordinal in attachment list to decode and return (typically, list has length 1) """ return self.credentials_attach[index].indy_dict
class CredentialIssueSchema (*args, **kwargs)
-
Credential schema.
Initialize an instance of AgentMessageSchema.
Raises
TypeError
- If Meta.model_class has not been set
Expand source code
class CredentialIssueSchema(AgentMessageSchema): """Credential schema.""" class Meta: """Credential schema metadata.""" model_class = CredentialIssue unknown = EXCLUDE comment = fields.Str( description="Human-readable comment", required=False, allow_none=True ) credentials_attach = fields.Nested( AttachDecoratorSchema, required=True, many=True, data_key="credentials~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 schema metadata.
var opts