ProposePresentation.fromJson constructor

ProposePresentation.fromJson(
  1. dynamic jsonObject
)

Implementation

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

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

    for (var a in attachments!) {
      if (a.format == AttachmentFormat.presentationDefinition) {
        a.data.resolveData();
        presentationDefinition!
            .add(PresentationDefinition.fromJson(a.data.json));
      } else if (a.format == AttachmentFormat.indyProofRequest) {
        throw UnimplementedError('Indy proof request is not supported');
      } else {
        throw Exception('Unknown type');
      }
    }
  }
}