EntertainmentConfiguration.fromJson constructor
Creates a EntertainmentConfiguration object from the JSON response to a GET request.
Implementation
factory EntertainmentConfiguration.fromJson(Map<String, dynamic> dataMap) {
// Handle entire response given with no filter.
Map<String, dynamic> data = MiscTools.extractData(dataMap);
final Map<String, dynamic> locations =
Map<String, dynamic>.from(data[ApiFields.locations] ?? {});
final List<dynamic>? serviceLocations =
locations[ApiFields.serviceLocations];
return EntertainmentConfiguration(
type: ResourceType.fromString(data[ApiFields.type] ?? ""),
id: data[ApiFields.id] ?? "",
idV1: data[ApiFields.idV1] ?? "",
metadata: EntertainmentConfigurationMetadata.fromJson(
Map<String, dynamic>.from(data[ApiFields.metadata] ?? {})),
name: data[ApiFields.name] ?? "",
configurationType: data[ApiFields.configurationType] ?? "",
status: data[ApiFields.status] ?? "",
activeStreamer: Relative.fromJson(
Map<String, dynamic>.from(data[ApiFields.activeStreamer] ?? {})),
streamProxy: EntertainmentConfigurationStreamProxy.fromJson(
Map<String, dynamic>.from(data[ApiFields.streamProxy] ?? {})),
channels: (data[ApiFields.channels] as List<dynamic>?)
?.map((channelMap) => EntertainmentConfigurationChannel.fromJson(
Map<String, dynamic>.from(channelMap)))
.toList() ??
[],
locations: serviceLocations
?.map((locationMap) =>
EntertainmentConfigurationLocation.fromJson(
Map<String, dynamic>.from(locationMap)))
.toList() ??
[],
lightServices: (data[ApiFields.lightServices] as List<dynamic>?)
?.map((lightServiceMap) =>
Relative.fromJson(Map<String, dynamic>.from(lightServiceMap)))
.toList() ??
[],
action: data[ApiFields.action],
);
}