Query.fromJson constructor

Query.fromJson(
  1. dynamic query
)

Implementation

Query.fromJson(dynamic query) {
  Map<String, dynamic> decoded = credentialToMap(query);
  if (decoded.containsKey('feature-type')) {
    var fType = decoded['feature-type'];
    if (fType == FeatureType.header.value) {
      featureType = FeatureType.header;
    } else if (fType == FeatureType.goalCode.value) {
      featureType = FeatureType.goalCode;
    } else if (fType == FeatureType.protocol.value) {
      featureType = FeatureType.protocol;
    } else if (fType == FeatureType.attachmentFormat.value) {
      featureType = FeatureType.attachmentFormat;
    } else {
      throw Exception('unknown Feature-type');
    }
  } else {
    throw Exception('Property Feature-Type is needed');
  }

  if (decoded.containsKey('match')) {
    match = decoded['match'];
  } else {
    throw Exception('Property match is needed');
  }
}