mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
connected all apis , create functionality is working
This commit is contained in:
@ -1,46 +1,54 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SceneModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String description;
|
||||
final String imageUrl;
|
||||
final String location;
|
||||
final String type;
|
||||
final String rating;
|
||||
final String price;
|
||||
final String duration;
|
||||
final String date;
|
||||
final String time;
|
||||
final String status;
|
||||
final Status status;
|
||||
final Type type;
|
||||
|
||||
SceneModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.imageUrl,
|
||||
required this.location,
|
||||
required this.type,
|
||||
required this.rating,
|
||||
required this.price,
|
||||
required this.duration,
|
||||
required this.date,
|
||||
required this.time,
|
||||
required this.status,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
factory SceneModel.fromJson(Map<String, dynamic> json) {
|
||||
return SceneModel(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
imageUrl: json['imageUrl'],
|
||||
location: json['location'],
|
||||
type: json['type'],
|
||||
rating: json['rating'],
|
||||
price: json['price'],
|
||||
duration: json['duration'],
|
||||
date: json['date'],
|
||||
time: json['time'],
|
||||
status: json['status'],
|
||||
);
|
||||
factory SceneModel.fromRawJson(String str) =>
|
||||
SceneModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory SceneModel.fromJson(Map<String, dynamic> json) => SceneModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: statusValues.map[json["status"]]!,
|
||||
type: typeValues.map[json["type"]]!,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"status": statusValues.reverse[status],
|
||||
"type": typeValues.reverse[type],
|
||||
};
|
||||
}
|
||||
|
||||
enum Status { ENABLE }
|
||||
|
||||
final statusValues = EnumValues({"enable": Status.ENABLE});
|
||||
|
||||
enum Type { TAP_TO_RUN }
|
||||
|
||||
final typeValues = EnumValues({"tap_to_run": Type.TAP_TO_RUN});
|
||||
|
||||
class EnumValues<T> {
|
||||
Map<String, T> map;
|
||||
late Map<T, String> reverseMap;
|
||||
|
||||
EnumValues(this.map);
|
||||
|
||||
Map<T, String> get reverse {
|
||||
reverseMap = map.map((k, v) => MapEntry(v, k));
|
||||
return reverseMap;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user