RequestPresentation.fromJson constructor

RequestPresentation.fromJson(
  1. dynamic jsonObject
)

Implementation

RequestPresentation.fromJson(dynamic jsonObject)
    : super.fromJson(jsonObject) {
  if (type != DidcommMessages.requestPresentation.value) {
    throw Exception('Unsupported type or version');
  }
  goalCode = body['goal_code'];
  comment = body['comment'];
  willConfirm = body['will_confirm'];

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

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