fromResult static method
Implementation
static PollMessage<dynamic>? fromResult(Map<String, dynamic>? json) {
if (json == null) {
return null;
}
// Contigo 15
if (json['type'] == 'mail.channel.partner/typing_status') {
return PollMessageInfo(
data: MessageInfoTyping.fromJson(
json['payload'] as Map<String, dynamic>,
),
payload: json['payload'] as Map<String, dynamic>,
);
}
if (json['type'] == 'mail.channel/new_message') {
final payload = json['payload'] as Map<String, dynamic>;
return PollMessageMessage(
data: Message.fromJson(payload['message'] as Map<String, dynamic>),
payload: json['payload'] as Map<String, dynamic>,
);
}
// Contigo 14
if (json['message_type'] != null) {
return PollMessageMessage.fromJson(json);
}
if (json['channel_type'] != null) {
return PollMessageChannel.fromJson(json);
}
if (json['info'] != null) {
return PollMessageInfo.fromJson(json);
}
return null;
}