bare implementation of comuncation with the api
This commit is contained in:
		| @@ -82,18 +82,16 @@ class UserPreferences { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   String toJson() { | ||||
|     // This is "opinionated" JSON, corresponding to the backend's expectations | ||||
|     return ''' | ||||
|     { | ||||
|       "sightseeing": {"type": "sightseeing", "score": ${sightseeing.value}}, | ||||
|       "shopping": {"type": "shopping", "score": ${shopping.value}}, | ||||
|       "nature": {"type": "nature", "score": ${nature.value}}, | ||||
|       "max_time_minutes": ${maxTime.value}, | ||||
|       "detour_tolerance_minute": ${maxDetour.value} | ||||
|   Map<String, dynamic> toJson() { | ||||
|       // This is "opinionated" JSON, corresponding to the backend's expectations | ||||
|       return { | ||||
|         "sightseeing": {"type": "sightseeing", "score": sightseeing.value}, | ||||
|         "shopping": {"type": "shopping", "score": shopping.value}, | ||||
|         "nature": {"type": "nature", "score": nature.value}, | ||||
|         "max_time_minute": maxTime.value, | ||||
|         "detour_tolerance_minute": maxDetour.value | ||||
|       }; | ||||
|     } | ||||
|     '''; | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -11,6 +11,7 @@ class Trip { | ||||
|   final String uuid; | ||||
|   final String cityName; | ||||
|   // TODO: cityName should be inferred from coordinates of the Landmarks | ||||
|   final int totalTime; | ||||
|   final LinkedList<Landmark> landmarks; | ||||
|   // could be empty as well | ||||
|  | ||||
| @@ -19,15 +20,18 @@ class Trip { | ||||
|     required this.uuid, | ||||
|     required this.cityName, | ||||
|     required this.landmarks, | ||||
|     this.totalTime = 0 | ||||
|   }); | ||||
|  | ||||
|  | ||||
|   factory Trip.fromJson(Map<String, dynamic> json) { | ||||
|     return Trip( | ||||
|     Trip trip = Trip( | ||||
|       uuid: json['uuid'], | ||||
|       cityName: json['city_name'], | ||||
|       cityName: json['city_name'] ?? 'Not communicated', | ||||
|       landmarks: LinkedList() | ||||
|     ); | ||||
|  | ||||
|     return trip; | ||||
|   } | ||||
|  | ||||
|  | ||||
| @@ -44,7 +48,7 @@ class Trip { | ||||
|   Map<String, dynamic> toJson() => { | ||||
|     'uuid': uuid, | ||||
|     'city_name': cityName, | ||||
|     'entry_uuid': landmarks.first?.uuid ?? '' | ||||
|     'first_landmark_uuid': landmarks.first.uuid | ||||
|   }; | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user