Bridge.fromJson constructor

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

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

Implementation

factory Bridge.fromJson(Map<String, dynamic> dataMap) {
  // Handle entire response given with no filter.
  Map<String, dynamic> data = MiscTools.extractData(dataMap);

  return Bridge(
    type: ResourceType.fromString(data[ApiFields.type] ?? ""),
    id: data[ApiFields.id] ?? "",
    idV1: data[ApiFields.idV1] ?? "",
    applicationKey: data[ApiFields.applicationKey],
    ipAddress: data[ApiFields.ipAddress],
    owner: Relative.fromJson(
        Map<String, dynamic>.from(data[ApiFields.owner] ?? {})),
    bridgeId: data[ApiFields.bridgeId] ?? "",
    timeZone: Map<String, dynamic>.from(
            data[ApiFields.timeZone] ?? {})[ApiFields.timeZone] ??
        "",
  );
}