ReactionType.fromJson constructor

ReactionType.fromJson(
  1. Map<String, dynamic> json
)

Creates a ReactionType object from JSON object

Implementation

factory ReactionType.fromJson(Map<String, dynamic> json) {
  switch (json['type']) {
    case 'emoji':
      return ReactionTypeEmoji.fromJson(json);
    case 'custom_emoji':
      return ReactionTypeCustomEmoji.fromJson(json);
    default:
      throw TeleverseException(
        'Invalid reaction type: ${json['type']}',
        description: 'The given type does not match any ReactionType.',
        type: TeleverseExceptionType.invalidParameter,
      );
  }
}