PresentationSubmission.fromJson constructor

PresentationSubmission.fromJson(
  1. dynamic jsonObject
)

Implementation

PresentationSubmission.fromJson(dynamic jsonObject) {
  Map<String, dynamic> submission = credentialToMap(jsonObject);
  if (submission.containsKey('id')) {
    id = submission['id'];
  } else {
    throw FormatException('Id Property is needed in presentation submission');
  }

  if (submission.containsKey('definition_id')) {
    presentationDefinitionId = submission['definition_id'];
  } else {
    throw FormatException(
        'Definition id is needed in presentation submission');
  }

  if (submission.containsKey('descriptor_map')) {
    List tmp = submission['descriptor_map'];
    descriptorMap = [];
    if (tmp.isNotEmpty) {
      for (var d in tmp) {
        descriptorMap.add(InputDescriptorMappingObject.fromJson(d));
      }
    }
  } else {
    throw FormatException(
        'descriptor_map property is needed in presentation submission');
  }

  _originalDoc = submission;
}