AdaIncident.fromJson constructor

AdaIncident.fromJson(
  1. Map<String, dynamic> json
)

Creates an AdaIncident object from a JSON object.

Implementation

factory AdaIncident.fromJson(Map<String, dynamic> json) {
  return AdaIncident(
    timeOfInitialReport:
        DateTime.tryParse(json[ApiFields.dateOutOfService] ?? '') ??
            emptyDateTime,
    timeOfLastUpdate:
        DateTime.tryParse(json[ApiFields.dateUpdated] ?? '') ?? emptyDateTime,
    estimatedTimeOfFix:
        DateTime.tryParse(json[ApiFields.estimatedTimeOfFix] ?? ''),
    locationDescription: json[ApiFields.locationDescription] ?? '',
    stationCode: json[ApiFields.stationCode] ?? '',
    stationName: json[ApiFields.stationName] ?? '',
    symptomDescription: json[ApiFields.symptomDescription] ?? '',
    unitName: json[ApiFields.unitName] ?? '',
    unitType: AdaUnitType.fromString(
        json[ApiFields.unitType] ?? AdaUnitType.unknown.value),
  );
}