Generate a map from the object
Map<String, dynamic> toMap() { return { 'type': type.value, 'data': data, }; }