tryDeserialize static method
Implementation
static DsaReportRequest tryDeserialize(
Map<String, dynamic> json, {
String key = 'report_type',
Map<Type, Object?>? mapping,
}) {
final mappingFallback = const <Type, Object?>{
DsaReportRequestMessage: 'message',
DsaReportRequestUser: 'user',
DsaReportRequestGuild: 'guild',
};
final value = json[key];
final effective = mapping ?? mappingFallback;
return switch (value) {
_ when value == effective[DsaReportRequestMessage] =>
DsaReportRequestMessage.fromJson(json),
_ when value == effective[DsaReportRequestUser] =>
DsaReportRequestUser.fromJson(json),
_ when value == effective[DsaReportRequestGuild] =>
DsaReportRequestGuild.fromJson(json),
_ => throw FormatException(
'Unknown discriminator value "${json[key]}" for DsaReportRequest',
),
};
}