RequestCredential.fromJson constructor

RequestCredential.fromJson(
  1. dynamic jsonObject
)

Implementation

RequestCredential.fromJson(super.jsonObject) : super.fromJson() {
  if (type != DidcommMessages.requestCredential) {
    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) {
        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) {
        credentialApplication = VerifiablePresentation.fromJson(a.data.json);
      } else if (a.format != null &&
          a.format == AttachmentFormat.indyCredentialRequest) {
        throw UnimplementedError('indy Attachment is not supported');
      } else {
        continue;
      }
    }
  }
}