LightSignaling.fromJson constructor

LightSignaling.fromJson(
  1. Map<String, dynamic> dataMap
)

Creates a LightSignaling object from the JSON response to a GET request.

Implementation

factory LightSignaling.fromJson(Map<String, dynamic> dataMap) {
  // Extract signal values from data map.
  List<String> signalValues =
      List<String>.from(dataMap[ApiFields.signalValues] ?? {});

  return LightSignaling(
    status: LightSignalingStatus.fromJson(
      {
        ...Map<String, dynamic>.from(dataMap[ApiFields.status] ?? {}),
        ...{ApiFields.signalValues: signalValues},
      },
    ),
    signalValues: signalValues,
  );
}