fromJson static method
Returns a native instance of an OpenAPI class matching the targetType
.
Implementation
static dynamic fromJson(
dynamic value,
String targetType, {
bool growable = false,
}) {
try {
switch (targetType) {
case 'String':
return value is String ? value : value.toString();
case 'int':
return value is int ? value : int.parse('$value');
case 'double':
return value is double ? value : double.parse('$value');
case 'bool':
if (value is bool) {
return value;
}
final valueString = '$value'.toLowerCase();
return valueString == 'true' || valueString == '1';
case 'DateTime':
return value is DateTime ? value : DateTime.tryParse(value);
case 'APIError':
return APIError.fromJson(value);
case 'AcceptCallResponse':
return AcceptCallResponse.fromJson(value);
case 'AggregatedStats':
return AggregatedStats.fromJson(value);
case 'AudioSettingsRequest':
return AudioSettingsRequest.fromJson(value);
case 'AudioSettingsResponse':
return AudioSettingsResponse.fromJson(value);
case 'BackstageSettingsRequest':
return BackstageSettingsRequest.fromJson(value);
case 'BackstageSettingsResponse':
return BackstageSettingsResponse.fromJson(value);
case 'BlockUserRequest':
return BlockUserRequest.fromJson(value);
case 'BlockUserResponse':
return BlockUserResponse.fromJson(value);
case 'BlockedUserEvent':
return BlockedUserEvent.fromJson(value);
case 'Bound':
return Bound.fromJson(value);
case 'BroadcastSettingsRequest':
return BroadcastSettingsRequest.fromJson(value);
case 'BroadcastSettingsResponse':
return BroadcastSettingsResponse.fromJson(value);
case 'CallAcceptedEvent':
return CallAcceptedEvent.fromJson(value);
case 'CallClosedCaption':
return CallClosedCaption.fromJson(value);
case 'CallClosedCaptionsFailedEvent':
return CallClosedCaptionsFailedEvent.fromJson(value);
case 'CallClosedCaptionsStartedEvent':
return CallClosedCaptionsStartedEvent.fromJson(value);
case 'CallClosedCaptionsStoppedEvent':
return CallClosedCaptionsStoppedEvent.fromJson(value);
case 'CallCreatedEvent':
return CallCreatedEvent.fromJson(value);
case 'CallDeletedEvent':
return CallDeletedEvent.fromJson(value);
case 'CallDurationReport':
return CallDurationReport.fromJson(value);
case 'CallDurationReportResponse':
return CallDurationReportResponse.fromJson(value);
case 'CallEndedEvent':
return CallEndedEvent.fromJson(value);
case 'CallEvent':
return CallEvent.fromJson(value);
case 'CallHLSBroadcastingFailedEvent':
return CallHLSBroadcastingFailedEvent.fromJson(value);
case 'CallHLSBroadcastingStartedEvent':
return CallHLSBroadcastingStartedEvent.fromJson(value);
case 'CallHLSBroadcastingStoppedEvent':
return CallHLSBroadcastingStoppedEvent.fromJson(value);
case 'CallIngressResponse':
return CallIngressResponse.fromJson(value);
case 'CallLiveStartedEvent':
return CallLiveStartedEvent.fromJson(value);
case 'CallMemberAddedEvent':
return CallMemberAddedEvent.fromJson(value);
case 'CallMemberRemovedEvent':
return CallMemberRemovedEvent.fromJson(value);
case 'CallMemberUpdatedEvent':
return CallMemberUpdatedEvent.fromJson(value);
case 'CallMemberUpdatedPermissionEvent':
return CallMemberUpdatedPermissionEvent.fromJson(value);
case 'CallMissedEvent':
return CallMissedEvent.fromJson(value);
case 'CallNotificationEvent':
return CallNotificationEvent.fromJson(value);
case 'CallParticipantCountReport':
return CallParticipantCountReport.fromJson(value);
case 'CallParticipantCountReportResponse':
return CallParticipantCountReportResponse.fromJson(value);
case 'CallParticipantResponse':
return CallParticipantResponse.fromJson(value);
case 'CallReactionEvent':
return CallReactionEvent.fromJson(value);
case 'CallRecording':
return CallRecording.fromJson(value);
case 'CallRecordingFailedEvent':
return CallRecordingFailedEvent.fromJson(value);
case 'CallRecordingReadyEvent':
return CallRecordingReadyEvent.fromJson(value);
case 'CallRecordingStartedEvent':
return CallRecordingStartedEvent.fromJson(value);
case 'CallRecordingStoppedEvent':
return CallRecordingStoppedEvent.fromJson(value);
case 'CallRejectedEvent':
return CallRejectedEvent.fromJson(value);
case 'CallRequest':
return CallRequest.fromJson(value);
case 'CallResponse':
return CallResponse.fromJson(value);
case 'CallRingEvent':
return CallRingEvent.fromJson(value);
case 'CallRtmpBroadcastFailedEvent':
return CallRtmpBroadcastFailedEvent.fromJson(value);
case 'CallRtmpBroadcastStartedEvent':
return CallRtmpBroadcastStartedEvent.fromJson(value);
case 'CallRtmpBroadcastStoppedEvent':
return CallRtmpBroadcastStoppedEvent.fromJson(value);
case 'CallSessionEndedEvent':
return CallSessionEndedEvent.fromJson(value);
case 'CallSessionParticipantCountsUpdatedEvent':
return CallSessionParticipantCountsUpdatedEvent.fromJson(value);
case 'CallSessionParticipantJoinedEvent':
return CallSessionParticipantJoinedEvent.fromJson(value);
case 'CallSessionParticipantLeftEvent':
return CallSessionParticipantLeftEvent.fromJson(value);
case 'CallSessionResponse':
return CallSessionResponse.fromJson(value);
case 'CallSessionStartedEvent':
return CallSessionStartedEvent.fromJson(value);
case 'CallSettingsRequest':
return CallSettingsRequest.fromJson(value);
case 'CallSettingsResponse':
return CallSettingsResponse.fromJson(value);
case 'CallStateResponseFields':
return CallStateResponseFields.fromJson(value);
case 'CallStatsReportSummaryResponse':
return CallStatsReportSummaryResponse.fromJson(value);
case 'CallTimeline':
return CallTimeline.fromJson(value);
case 'CallTranscription':
return CallTranscription.fromJson(value);
case 'CallTranscriptionFailedEvent':
return CallTranscriptionFailedEvent.fromJson(value);
case 'CallTranscriptionReadyEvent':
return CallTranscriptionReadyEvent.fromJson(value);
case 'CallTranscriptionStartedEvent':
return CallTranscriptionStartedEvent.fromJson(value);
case 'CallTranscriptionStoppedEvent':
return CallTranscriptionStoppedEvent.fromJson(value);
case 'CallUpdatedEvent':
return CallUpdatedEvent.fromJson(value);
case 'CallUserMutedEvent':
return CallUserMutedEvent.fromJson(value);
case 'CallsPerDayReport':
return CallsPerDayReport.fromJson(value);
case 'CallsPerDayReportResponse':
return CallsPerDayReportResponse.fromJson(value);
case 'ClosedCaptionEvent':
return ClosedCaptionEvent.fromJson(value);
case 'CollectUserFeedbackRequest':
return CollectUserFeedbackRequest.fromJson(value);
case 'CollectUserFeedbackResponse':
return CollectUserFeedbackResponse.fromJson(value);
case 'ConnectUserDetailsRequest':
return ConnectUserDetailsRequest.fromJson(value);
case 'ConnectedEvent':
return ConnectedEvent.fromJson(value);
case 'ConnectionErrorEvent':
return ConnectionErrorEvent.fromJson(value);
case 'Coordinates':
return Coordinates.fromJson(value);
case 'Count':
return Count.fromJson(value);
case 'CountrywiseAggregateStats':
return CountrywiseAggregateStats.fromJson(value);
case 'CreateDeviceRequest':
return CreateDeviceRequest.fromJson(value);
case 'CreateGuestRequest':
return CreateGuestRequest.fromJson(value);
case 'CreateGuestResponse':
return CreateGuestResponse.fromJson(value);
case 'Credentials':
return Credentials.fromJson(value);
case 'CustomVideoEvent':
return CustomVideoEvent.fromJson(value);
case 'DailyAggregateCallDurationReportResponse':
return DailyAggregateCallDurationReportResponse.fromJson(value);
case 'DailyAggregateCallParticipantCountReportResponse':
return DailyAggregateCallParticipantCountReportResponse.fromJson(
value);
case 'DailyAggregateCallsPerDayReportResponse':
return DailyAggregateCallsPerDayReportResponse.fromJson(value);
case 'DailyAggregateQualityScoreReportResponse':
return DailyAggregateQualityScoreReportResponse.fromJson(value);
case 'DailyAggregateSDKUsageReportResponse':
return DailyAggregateSDKUsageReportResponse.fromJson(value);
case 'DailyAggregateUserFeedbackReportResponse':
return DailyAggregateUserFeedbackReportResponse.fromJson(value);
case 'DeleteCallRequest':
return DeleteCallRequest.fromJson(value);
case 'DeleteCallResponse':
return DeleteCallResponse.fromJson(value);
case 'DeleteRecordingResponse':
return DeleteRecordingResponse.fromJson(value);
case 'DeleteTranscriptionResponse':
return DeleteTranscriptionResponse.fromJson(value);
case 'DeviceResponse':
return DeviceResponse.fromJson(value);
case 'EdgeResponse':
return EdgeResponse.fromJson(value);
case 'EgressHLSResponse':
return EgressHLSResponse.fromJson(value);
case 'EgressRTMPResponse':
return EgressRTMPResponse.fromJson(value);
case 'EgressResponse':
return EgressResponse.fromJson(value);
case 'EndCallResponse':
return EndCallResponse.fromJson(value);
case 'GeofenceSettingsRequest':
return GeofenceSettingsRequest.fromJson(value);
case 'GeofenceSettingsResponse':
return GeofenceSettingsResponse.fromJson(value);
case 'GeolocationResult':
return GeolocationResult.fromJson(value);
case 'GetCallResponse':
return GetCallResponse.fromJson(value);
case 'GetCallStatsResponse':
return GetCallStatsResponse.fromJson(value);
case 'GetEdgesResponse':
return GetEdgesResponse.fromJson(value);
case 'GetOrCreateCallRequest':
return GetOrCreateCallRequest.fromJson(value);
case 'GetOrCreateCallResponse':
return GetOrCreateCallResponse.fromJson(value);
case 'GoLiveRequest':
return GoLiveRequest.fromJson(value);
case 'GoLiveResponse':
return GoLiveResponse.fromJson(value);
case 'HLSSettingsRequest':
return HLSSettingsRequest.fromJson(value);
case 'HLSSettingsResponse':
return HLSSettingsResponse.fromJson(value);
case 'HealthCheckEvent':
return HealthCheckEvent.fromJson(value);
case 'ICEServer':
return ICEServer.fromJson(value);
case 'JoinCallRequest':
return JoinCallRequest.fromJson(value);
case 'JoinCallResponse':
return JoinCallResponse.fromJson(value);
case 'LayoutSettingsRequest':
return LayoutSettingsRequest.fromJson(value);
case 'LimitsSettingsRequest':
return LimitsSettingsRequest.fromJson(value);
case 'LimitsSettingsResponse':
return LimitsSettingsResponse.fromJson(value);
case 'ListDevicesResponse':
return ListDevicesResponse.fromJson(value);
case 'ListRecordingsResponse':
return ListRecordingsResponse.fromJson(value);
case 'ListTranscriptionsResponse':
return ListTranscriptionsResponse.fromJson(value);
case 'Location':
return Location.fromJson(value);
case 'MediaPubSubHint':
return MediaPubSubHint.fromJson(value);
case 'MemberRequest':
return MemberRequest.fromJson(value);
case 'MemberResponse':
return MemberResponse.fromJson(value);
case 'MuteUsersRequest':
return MuteUsersRequest.fromJson(value);
case 'MuteUsersResponse':
return MuteUsersResponse.fromJson(value);
case 'NetworkMetricsReportResponse':
return NetworkMetricsReportResponse.fromJson(value);
case 'NoiseCancellationSettings':
return NoiseCancellationSettings.fromJson(value);
case 'OwnCapability':
return OwnCapabilityTypeTransformer().decode(value);
case 'OwnUserResponse':
return OwnUserResponse.fromJson(value);
case 'PerSDKUsageReport':
return PerSDKUsageReport.fromJson(value);
case 'PermissionRequestEvent':
return PermissionRequestEvent.fromJson(value);
case 'PinRequest':
return PinRequest.fromJson(value);
case 'PinResponse':
return PinResponse.fromJson(value);
case 'PublishedTrackInfo':
return PublishedTrackInfo.fromJson(value);
case 'PublisherAggregateStats':
return PublisherAggregateStats.fromJson(value);
case 'PushNotificationSettingsResponse':
return PushNotificationSettingsResponse.fromJson(value);
case 'QualityScoreReport':
return QualityScoreReport.fromJson(value);
case 'QualityScoreReportResponse':
return QualityScoreReportResponse.fromJson(value);
case 'QueryAggregateCallStatsRequest':
return QueryAggregateCallStatsRequest.fromJson(value);
case 'QueryAggregateCallStatsResponse':
return QueryAggregateCallStatsResponse.fromJson(value);
case 'QueryCallMembersRequest':
return QueryCallMembersRequest.fromJson(value);
case 'QueryCallMembersResponse':
return QueryCallMembersResponse.fromJson(value);
case 'QueryCallStatsRequest':
return QueryCallStatsRequest.fromJson(value);
case 'QueryCallStatsResponse':
return QueryCallStatsResponse.fromJson(value);
case 'QueryCallsRequest':
return QueryCallsRequest.fromJson(value);
case 'QueryCallsResponse':
return QueryCallsResponse.fromJson(value);
case 'RTMPBroadcastRequest':
return RTMPBroadcastRequest.fromJson(value);
case 'RTMPIngress':
return RTMPIngress.fromJson(value);
case 'RTMPSettingsRequest':
return RTMPSettingsRequest.fromJson(value);
case 'RTMPSettingsResponse':
return RTMPSettingsResponse.fromJson(value);
case 'ReactionResponse':
return ReactionResponse.fromJson(value);
case 'RecordSettingsRequest':
return RecordSettingsRequest.fromJson(value);
case 'RecordSettingsResponse':
return RecordSettingsResponse.fromJson(value);
case 'RejectCallRequest':
return RejectCallRequest.fromJson(value);
case 'RejectCallResponse':
return RejectCallResponse.fromJson(value);
case 'ReportByHistogramBucket':
return ReportByHistogramBucket.fromJson(value);
case 'RequestPermissionRequest':
return RequestPermissionRequest.fromJson(value);
case 'RequestPermissionResponse':
return RequestPermissionResponse.fromJson(value);
// MANUAL_EDIT: Response -> DurationResponse
case 'DurationResponse':
return DurationResponse.fromJson(value);
case 'RingSettingsRequest':
return RingSettingsRequest.fromJson(value);
case 'RingSettingsResponse':
return RingSettingsResponse.fromJson(value);
case 'SDKUsageReport':
return SDKUsageReport.fromJson(value);
case 'SDKUsageReportResponse':
return SDKUsageReportResponse.fromJson(value);
case 'SFULocationResponse':
return SFULocationResponse.fromJson(value);
case 'SFUResponse':
return SFUResponse.fromJson(value);
case 'ScreensharingSettingsRequest':
return ScreensharingSettingsRequest.fromJson(value);
case 'ScreensharingSettingsResponse':
return ScreensharingSettingsResponse.fromJson(value);
case 'SendCallEventRequest':
return SendCallEventRequest.fromJson(value);
case 'SendCallEventResponse':
return SendCallEventResponse.fromJson(value);
case 'SendReactionRequest':
return SendReactionRequest.fromJson(value);
case 'SendReactionResponse':
return SendReactionResponse.fromJson(value);
case 'SortParamRequest':
return SortParamRequest.fromJson(value);
case 'StartClosedCaptionsRequest':
return StartClosedCaptionsRequest.fromJson(value);
case 'StartClosedCaptionsResponse':
return StartClosedCaptionsResponse.fromJson(value);
case 'StartHLSBroadcastingResponse':
return StartHLSBroadcastingResponse.fromJson(value);
case 'StartRTMPBroadcastsRequest':
return StartRTMPBroadcastsRequest.fromJson(value);
case 'StartRTMPBroadcastsResponse':
return StartRTMPBroadcastsResponse.fromJson(value);
case 'StartRecordingRequest':
return StartRecordingRequest.fromJson(value);
case 'StartRecordingResponse':
return StartRecordingResponse.fromJson(value);
case 'StartTranscriptionRequest':
return StartTranscriptionRequest.fromJson(value);
case 'StartTranscriptionResponse':
return StartTranscriptionResponse.fromJson(value);
case 'StatsOptions':
return StatsOptions.fromJson(value);
case 'StopAllRTMPBroadcastsResponse':
return StopAllRTMPBroadcastsResponse.fromJson(value);
case 'StopClosedCaptionsRequest':
return StopClosedCaptionsRequest.fromJson(value);
case 'StopClosedCaptionsResponse':
return StopClosedCaptionsResponse.fromJson(value);
case 'StopHLSBroadcastingResponse':
return StopHLSBroadcastingResponse.fromJson(value);
case 'StopLiveRequest':
return StopLiveRequest.fromJson(value);
case 'StopLiveResponse':
return StopLiveResponse.fromJson(value);
case 'StopRTMPBroadcastsResponse':
return StopRTMPBroadcastsResponse.fromJson(value);
case 'StopRecordingResponse':
return StopRecordingResponse.fromJson(value);
case 'StopTranscriptionRequest':
return StopTranscriptionRequest.fromJson(value);
case 'StopTranscriptionResponse':
return StopTranscriptionResponse.fromJson(value);
case 'Subsession':
return Subsession.fromJson(value);
case 'TURNAggregatedStats':
return TURNAggregatedStats.fromJson(value);
case 'TargetResolution':
return TargetResolution.fromJson(value);
case 'ThumbnailResponse':
return ThumbnailResponse.fromJson(value);
case 'ThumbnailsSettingsRequest':
return ThumbnailsSettingsRequest.fromJson(value);
case 'ThumbnailsSettingsResponse':
return ThumbnailsSettingsResponse.fromJson(value);
case 'TimeStats':
return TimeStats.fromJson(value);
case 'TranscriptionSettingsRequest':
return TranscriptionSettingsRequest.fromJson(value);
case 'TranscriptionSettingsResponse':
return TranscriptionSettingsResponse.fromJson(value);
case 'UnblockUserRequest':
return UnblockUserRequest.fromJson(value);
case 'UnblockUserResponse':
return UnblockUserResponse.fromJson(value);
case 'UnblockedUserEvent':
return UnblockedUserEvent.fromJson(value);
case 'UnpinRequest':
return UnpinRequest.fromJson(value);
case 'UnpinResponse':
return UnpinResponse.fromJson(value);
case 'UpdateCallMembersRequest':
return UpdateCallMembersRequest.fromJson(value);
case 'UpdateCallMembersResponse':
return UpdateCallMembersResponse.fromJson(value);
case 'UpdateCallRequest':
return UpdateCallRequest.fromJson(value);
case 'UpdateCallResponse':
return UpdateCallResponse.fromJson(value);
case 'UpdateUserPermissionsRequest':
return UpdateUserPermissionsRequest.fromJson(value);
case 'UpdateUserPermissionsResponse':
return UpdateUserPermissionsResponse.fromJson(value);
case 'UpdatedCallPermissionsEvent':
return UpdatedCallPermissionsEvent.fromJson(value);
case 'UserEventPayload':
return UserEventPayload.fromJson(value);
case 'UserFeedbackReport':
return UserFeedbackReport.fromJson(value);
case 'UserFeedbackReportResponse':
return UserFeedbackReportResponse.fromJson(value);
case 'UserInfoResponse':
return UserInfoResponse.fromJson(value);
case 'UserRequest':
return UserRequest.fromJson(value);
case 'UserResponse':
return UserResponse.fromJson(value);
case 'UserSessionStats':
return UserSessionStats.fromJson(value);
case 'UserStats':
return UserStats.fromJson(value);
case 'UserUpdatedEvent':
return UserUpdatedEvent.fromJson(value);
case 'VideoDimension':
return VideoDimension.fromJson(value);
case 'VideoEvent':
return VideoEvent.fromJson(value);
case 'VideoQuality':
return VideoQuality.fromJson(value);
case 'VideoSettingsRequest':
return VideoSettingsRequest.fromJson(value);
case 'VideoSettingsResponse':
return VideoSettingsResponse.fromJson(value);
case 'WSAuthMessage':
return WSAuthMessage.fromJson(value);
default:
dynamic match;
if (value is List &&
(match = _regList.firstMatch(targetType)?.group(1)) != null) {
return value
.map<dynamic>((dynamic v) => fromJson(
v,
match,
growable: growable,
))
.toList(growable: growable);
}
if (value is Set &&
(match = _regSet.firstMatch(targetType)?.group(1)) != null) {
return value
.map<dynamic>((dynamic v) => fromJson(
v,
match,
growable: growable,
))
.toSet();
}
if (value is Map &&
(match = _regMap.firstMatch(targetType)?.group(1)) != null) {
return Map<String, dynamic>.fromIterables(
value.keys.cast<String>(),
value.values.map<dynamic>((dynamic v) => fromJson(
v,
match,
growable: growable,
)),
);
}
}
} on Exception catch (error, trace) {
throw ApiException.withInner(
HttpStatus.internalServerError,
'Exception during deserialization.',
error,
trace,
);
}
throw ApiException(
HttpStatus.internalServerError,
'Could not find a suitable class for deserialization',
);
}