import 'package:fluffychat/pangea/activity_generator/media_enum.dart'; import 'package:fluffychat/pangea/common/constants/model_keys.dart'; import 'package:fluffychat/pangea/learning_settings/language_level_type_enum.dart'; class ActivityPlanRequest { final String topic; final String mode; final String objective; final String location; final MediaEnum media; LanguageLevelTypeEnum cefrLevel; final String languageOfInstructions; final String targetLanguage; final int count; int numberOfParticipants; ActivityPlanRequest({ required this.topic, required this.mode, required this.objective, required this.media, required this.cefrLevel, required this.languageOfInstructions, required this.targetLanguage, this.location = "any", this.count = 3, required this.numberOfParticipants, }); Map toJson() { return { ModelKey.activityRequestTopic: topic, ModelKey.mode: mode, ModelKey.activityRequestObjective: objective, ModelKey.activityRequestMedia: media.string, ModelKey.activityRequestCefrLevel: cefrLevel.string, ModelKey.activityRequestLanguageOfInstructions: languageOfInstructions, ModelKey.targetLanguage: targetLanguage, ModelKey.activityRequestCount: count, ModelKey.activityRequestNumberOfParticipants: numberOfParticipants, ModelKey.activityPlanLocation: location, }; } factory ActivityPlanRequest.fromJson(Map json) => ActivityPlanRequest( topic: json[ModelKey.activityRequestTopic], mode: json[ModelKey.mode], objective: json[ModelKey.activityRequestObjective], media: MediaEnum.nan.fromString(json[ModelKey.activityRequestMedia]), cefrLevel: json[ModelKey.activityRequestCefrLevel] != null ? LanguageLevelTypeEnum.fromString( json[ModelKey.activityRequestCefrLevel], ) : LanguageLevelTypeEnum.a1, languageOfInstructions: json[ModelKey.activityRequestLanguageOfInstructions], targetLanguage: json[ModelKey.targetLanguage], count: json[ModelKey.activityRequestCount], numberOfParticipants: json[ModelKey.activityRequestNumberOfParticipants], location: json[ModelKey.activityPlanLocation] ?? "any", ); String get storageKey => '$topic-$mode-$objective-${media.string}-$cefrLevel-$languageOfInstructions-$targetLanguage-$numberOfParticipants'; @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is ActivityPlanRequest && other.topic == topic && other.mode == mode && other.objective == objective && other.media == media && other.cefrLevel == cefrLevel && other.languageOfInstructions == languageOfInstructions && other.targetLanguage == targetLanguage && other.location == location && other.count == count && other.numberOfParticipants == numberOfParticipants; } @override int get hashCode => topic.hashCode ^ mode.hashCode ^ objective.hashCode ^ media.hashCode ^ cefrLevel.hashCode ^ languageOfInstructions.hashCode ^ targetLanguage.hashCode ^ count.hashCode ^ location.hashCode ^ numberOfParticipants.hashCode; }