Presentation.fromJson constructor

Presentation.fromJson(
  1. dynamic jsonObject
)

Implementation

Presentation.fromJson(super.jsonObject) : super.fromJson() {
  if (type != DidcommMessages.presentation) {
    throw Exception('Unsupported type or version');
  }
  goalCode = body['goal_code'];
  comment = body['comment'];

  if (attachments != null && attachments!.isNotEmpty) {
    verifiablePresentation = [];

    for (var a in attachments!) {
      if (a.format == AttachmentFormat.presentationSubmission ||
          a.format == AttachmentFormat.presentationSubmission2) {
        a.data.resolveData();
        var tmp = VerifiablePresentation.fromJson(a.data.json);
        if (tmp.presentationSubmission == null) {
          throw Exception(
              'The verifiable Presentation used here must contain a presentation submission');
        }
        verifiablePresentation.add(tmp);
      } else if (a.format == AttachmentFormat.indyProof) {
        throw UnimplementedError('Indy proof request is not supported');
      } else {
        //throw Exception('Unknown type: ${a.format}');
      }
    }
  }
}