fromJson static method

CallSessionResponse? fromJson(
  1. dynamic value
)

Returns a new CallSessionResponse instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static CallSessionResponse? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'accepted_by'),
          'Required key "CallSessionResponse[accepted_by]" is missing from JSON.');
      assert(json[r'accepted_by'] != null,
          'Required key "CallSessionResponse[accepted_by]" has a null value in JSON.');
      assert(json.containsKey(r'anonymous_participant_count'),
          'Required key "CallSessionResponse[anonymous_participant_count]" is missing from JSON.');
      assert(json[r'anonymous_participant_count'] != null,
          'Required key "CallSessionResponse[anonymous_participant_count]" has a null value in JSON.');
      assert(json.containsKey(r'id'),
          'Required key "CallSessionResponse[id]" is missing from JSON.');
      assert(json[r'id'] != null,
          'Required key "CallSessionResponse[id]" has a null value in JSON.');
      assert(json.containsKey(r'missed_by'),
          'Required key "CallSessionResponse[missed_by]" is missing from JSON.');
      assert(json[r'missed_by'] != null,
          'Required key "CallSessionResponse[missed_by]" has a null value in JSON.');
      assert(json.containsKey(r'participants'),
          'Required key "CallSessionResponse[participants]" is missing from JSON.');
      assert(json[r'participants'] != null,
          'Required key "CallSessionResponse[participants]" has a null value in JSON.');
      assert(json.containsKey(r'participants_count_by_role'),
          'Required key "CallSessionResponse[participants_count_by_role]" is missing from JSON.');
      assert(json[r'participants_count_by_role'] != null,
          'Required key "CallSessionResponse[participants_count_by_role]" has a null value in JSON.');
      assert(json.containsKey(r'rejected_by'),
          'Required key "CallSessionResponse[rejected_by]" is missing from JSON.');
      assert(json[r'rejected_by'] != null,
          'Required key "CallSessionResponse[rejected_by]" has a null value in JSON.');
      return true;
    }());

    return CallSessionResponse(
      // MANUAL_EDIT: mapCastOfType().convertValueToDateTime() instead of mapFromJson()
      acceptedBy: mapCastOfType<String, String>(json, r'accepted_by')!
          .convertValueToDateTime(),
      anonymousParticipantCount:
          mapValueOfType<int>(json, r'anonymous_participant_count')!,
      endedAt: mapDateTime(json, r'ended_at', r''),
      id: mapValueOfType<String>(json, r'id')!,
      liveEndedAt: mapDateTime(json, r'live_ended_at', r''),
      liveStartedAt: mapDateTime(json, r'live_started_at', r''),
      // MANUAL_EDIT: mapCastOfType().convertValueToDateTime() instead of mapFromJson()
      missedBy: mapCastOfType<String, String>(json, r'missed_by')!
          .convertValueToDateTime(),
      participants:
          CallParticipantResponse.listFromJson(json[r'participants']),
      participantsCountByRole:
          mapCastOfType<String, int>(json, r'participants_count_by_role')!,
      // MANUAL_EDIT: mapCastOfType().convertValueToDateTime() instead of mapFromJson()
      rejectedBy: mapCastOfType<String, String>(json, r'rejected_by')!
          .convertValueToDateTime(),
      startedAt: mapDateTime(json, r'started_at', r''),
      timerEndsAt: mapDateTime(json, r'timer_ends_at', r''),
    );
  }
  return null;
}