Recall.fromRdw constructor

Recall.fromRdw(
  1. Map<String, Object?> status, [
  2. Map<String, Object?>? details
])

Reads a record from the recall status dataset and, if there is one, the matching record from the recall dataset.

Throws a FormatException if status has no reference code.

Implementation

factory Recall.fromRdw(
  Map<String, Object?> status, [
  Map<String, Object?>? details,
]) {
  final statusRow = RdwRow(status);
  final detailRow = RdwRow(details ?? const {});
  return Recall._(
    referenceCode: statusRow.requiredText('referentiecode_rdw'),
    status: RecallStatus._fromCode(statusRow.text('code_status')),
    manufacturer: detailRow.text('meldende_producent_distributeur'),
    manufacturerReference: detailRow.text('referentiecode_producent'),
    defect: detailRow.text('omschrijving_defect'),
    defectCategory: detailRow.text('categorie_defect'),
    consequences: detailRow.text('materi_le_gevolgen'),
    remedy: detailRow.text('beschrijving_van_het_herstel'),
    moreInfoUrl: switch (detailRow.text('meer_informatie_op_internet')) {
      final url? => Uri.tryParse(url),
      null => null,
    },
    moreInfoPhone: detailRow.text('meer_informatie_via_telefoonnummer'),
    publishedOn: detailRow.date('publicatiedatum_rdw'),
    riskAssessment: detailRow.text('risicobeoordeling_rdw'),
    affectedVehicles: detailRow.integer(
      'totaal_aantal_voertuigen_terugroepactie',
    ),
  );
}