Entertainment.fromJson constructor

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

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

Implementation

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

  return Entertainment(
    type: ResourceType.fromString(data[ApiFields.type] ?? ""),
    id: data[ApiFields.id] ?? "",
    idV1: data[ApiFields.idV1] ?? "",
    owner: Relative.fromJson(
        Map<String, dynamic>.from(data[ApiFields.owner] ?? {})),
    isRenderer: data[ApiFields.isRenderer] ?? false,
    isProxy: data[ApiFields.isProxy] ?? false,
    isEqualizer: data[ApiFields.isEqualizer] ?? false,
    maxStreams: data[ApiFields.maxStreams] ?? 1,
    segmentCapabilities: EntertainmentSegmentCapabilities.fromJson(
        Map<String, dynamic>.from(data[ApiFields.segments] ?? {})),
  );
}