IssueCredential.fromJson constructor

IssueCredential.fromJson(
  1. dynamic jsonObject
)

Implementation

IssueCredential.fromJson(super.jsonObject) : super.fromJson() {
  if (type != DidcommMessages.issueCredential) {
    throw Exception('Unknown Message type or version');
  }
  goalCode = body['goal_code'];
  comment = body['comment'];
  replacementId = body['replacement_id'];
  if (attachments != null && attachments!.isNotEmpty) {
    credentials = [];
    for (var a in attachments!) {
      if (a.format != null && a.format == AttachmentFormat.ldProofVc) {
        if (a.mediaType != null && a.mediaType == 'application/json') {
          a.data.resolveData();
          credentials!.add(VerifiableCredential.fromJson(a.data.json!));
        }
      } else if (a.format != null &&
          a.format == AttachmentFormat.credentialFulfillment) {
        credentialFulfillment = VerifiablePresentation.fromJson(a.data.json);
      } else if (a.format != null &&
          a.format == AttachmentFormat.indyCredential) {
        throw UnimplementedError('indy Attachment is not supported');
      } else {
        throw Exception('Unknown Attachment Format');
      }
    }
  }
}