fromJson static method

CallParticipantResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CallParticipantResponse? 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'joined_at'),
          'Required key "CallParticipantResponse[joined_at]" is missing from JSON.');
      assert(json[r'joined_at'] != null,
          'Required key "CallParticipantResponse[joined_at]" has a null value in JSON.');
      assert(json.containsKey(r'role'),
          'Required key "CallParticipantResponse[role]" is missing from JSON.');
      assert(json[r'role'] != null,
          'Required key "CallParticipantResponse[role]" has a null value in JSON.');
      assert(json.containsKey(r'user'),
          'Required key "CallParticipantResponse[user]" is missing from JSON.');
      assert(json[r'user'] != null,
          'Required key "CallParticipantResponse[user]" has a null value in JSON.');
      assert(json.containsKey(r'user_session_id'),
          'Required key "CallParticipantResponse[user_session_id]" is missing from JSON.');
      assert(json[r'user_session_id'] != null,
          'Required key "CallParticipantResponse[user_session_id]" has a null value in JSON.');
      return true;
    }());

    return CallParticipantResponse(
      joinedAt: mapDateTime(json, r'joined_at', r'')!,
      role: mapValueOfType<String>(json, r'role')!,
      user: UserResponse.fromJson(json[r'user'])!,
      userSessionId: mapValueOfType<String>(json, r'user_session_id')!,
    );
  }
  return null;
}