Geolocation.fromJson constructor

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

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

Implementation

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

  return Geolocation(
    type: ResourceType.fromString(data[ApiFields.type] ?? ""),
    id: data[ApiFields.id] ?? "",
    idV1: data[ApiFields.idV1] ?? "",
    isConfigured: data[ApiFields.isConfigured] ?? false,
    latitude: (data[ApiFields.latitude] as num?)?.toDouble(),
    longitude: (data[ApiFields.longitude] as num?)?.toDouble(),
  );
}