Presentation.fromJson constructor

Presentation.fromJson(
  1. dynamic jsonObject
)

Implementation

Presentation.fromJson(dynamic jsonObject) : super.fromJson(jsonObject) {
  if (type != DidcommMessages.presentation.value) {
    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.value ||
          a.format == AttachmentFormat.presentationSubmission2.value) {
        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.value) {
        throw UnimplementedError('Indy proof request is not supported');
      } else {
        throw Exception('Unknown type: ${a.format}');
      }
    }
  }
}