RequestCredential.fromJson constructor

RequestCredential.fromJson(
  1. dynamic jsonObject
)

Implementation

RequestCredential.fromJson(dynamic jsonObject) : super.fromJson(jsonObject) {
  if (type != DidcommMessages.requestCredential.value) {
    throw Exception('Unknown Message type or version');
  }
  goalCode = body['goal_code'];
  comment = body['comment'];
  if (attachments != null && attachments!.isNotEmpty) {
    detail = [];
    for (var a in attachments!) {
      if (a.format != null &&
          a.format == AttachmentFormat.ldProofVcDetail.value) {
        if (a.mediaType != null && a.mediaType == 'application/json') {
          a.data.resolveData();
          detail!.add(LdProofVcDetail.fromJson(a.data.json!));
        }
      } else if (a.format != null &&
          a.format == 'dif/credential-manifest@v1.0') {
        throw UnimplementedError(
            'dif credential Manifest Attachment as described in Aries RFC 511 is not supported yet');
      } else if (a.format != null &&
          a.format == AttachmentFormat.credentialApplication.value) {
        credentialApplication = VerifiablePresentation.fromJson(a.data.json);
      } else if (a.format != null &&
          a.format == AttachmentFormat.indyCredentialRequest.value) {
        throw UnimplementedError('indy Attachment is not supported');
      } else {
        continue;
      }
    }
  }
}