fromJson static method
Returns a new WSEvent instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static WSEvent? 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "WSEvent[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "WSEvent[$key]" has a null value in JSON.');
});
return true;
}());
return WSEvent(
blockedByUser: UserResponse.fromJson(json[r'blocked_by_user']),
callCid: mapValueOfType<String>(json, r'call_cid')!,
createdAt: mapDateTime(json, r'created_at', r'')!,
type: mapValueOfType<String>(json, r'type')!,
user: UserObject.fromJson(json[r'user'])!,
call: CallResponse.fromJson(json[r'call'])!,
members: MemberResponse.listFromJson(json[r'members']),
hlsPlaylistUrl: mapValueOfType<String>(json, r'hls_playlist_url')!,
// MANUAL_EDIT: List to List<String>
capabilitiesByRole: json[r'capabilities_by_role'] == null
? const {}
: mapCastOfType<String, List<String>>(json, r'capabilities_by_role') ?? const {},
notifyUser: mapValueOfType<bool>(json, r'notify_user')!,
sessionId: mapValueOfType<String>(json, r'session_id')!,
reaction: ReactionResponse.fromJson(json[r'reaction'])!,
callRecording: CallRecording.fromJson(json[r'call_recording'])!,
reason: mapValueOfType<String>(json, r'reason'),
video: mapValueOfType<bool>(json, r'video')!,
name: mapValueOfType<String>(json, r'name')!,
anonymousParticipantCount: mapValueOfType<int>(json, r'anonymous_participant_count')!,
participantsCountByRole: mapCastOfType<String, int>(json, r'participants_count_by_role')!,
participant: CallParticipantResponse.fromJson(json[r'participant'])!,
callTranscription: CallTranscription.fromJson(json[r'call_transcription'])!,
fromUserId: mapValueOfType<String>(json, r'from_user_id')!,
mutedUserIds: json[r'muted_user_ids'] is Iterable
? (json[r'muted_user_ids'] as Iterable).cast<String>().toList(growable: false)
: const [],
closedCaption: CallClosedCaption.fromJson(json[r'closed_caption'])!,
connectionId: mapValueOfType<String>(json, r'connection_id')!,
me: OwnUserResponse.fromJson(json[r'me'])!,
error: APIError.fromJson(json[r'error'])!,
custom: mapCastOfType<String, Object>(json, r'custom')!,
item: ReviewQueueItem.fromJson(json[r'item']),
message: Message.fromJson(json[r'message']),
objectId: mapValueOfType<String>(json, r'object_id'),
permissions: json[r'permissions'] is Iterable
? (json[r'permissions'] as Iterable).cast<String>().toList(growable: false)
: const [],
ownCapabilities: OwnCapability.listFromJson(json[r'own_capabilities']),
channelId: mapValueOfType<String>(json, r'channel_id')!,
channelType: mapValueOfType<String>(json, r'channel_type')!,
cid: mapValueOfType<String>(json, r'cid')!,
createdBy: UserObject.fromJson(json[r'created_by'])!,
expiration: mapDateTime(json, r'expiration', r''),
shadow: mapValueOfType<bool>(json, r'shadow')!,
team: mapValueOfType<String>(json, r'team'),
deleteConversationChannels: mapValueOfType<bool>(json, r'delete_conversation_channels')!,
hardDelete: mapValueOfType<bool>(json, r'hard_delete')!,
markMessagesDeleted: mapValueOfType<bool>(json, r'mark_messages_deleted')!,
targetUser: mapValueOfType<String>(json, r'target_user'),
targetUsers: json[r'target_users'] is Iterable
? (json[r'target_users'] as Iterable).cast<String>().toList(growable: false)
: const [],
);
}
return null;
}