Files
syncrow-app/lib/features/scene/model/scene_details_model.dart
ashrafzarkanisala 75fe80e72a commit last changes
2024-07-01 22:31:50 +03:00

94 lines
2.3 KiB
Dart

import 'dart:convert';
class SceneDetailsModel {
final String id;
final String name;
final String status;
final String type;
final List<Action> actions;
SceneDetailsModel({
required this.id,
required this.name,
required this.status,
required this.type,
required this.actions,
});
factory SceneDetailsModel.fromRawJson(String str) =>
SceneDetailsModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) =>
SceneDetailsModel(
id: json["id"],
name: json["name"],
status: json["status"],
type: json["type"],
actions:
List<Action>.from(json["actions"].map((x) => Action.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"status": status,
"type": type,
"actions": List<dynamic>.from(actions.map((x) => x.toJson())),
};
}
class Action {
final String actionExecutor;
final String entityId;
final ExecutorProperty executorProperty;
Action({
required this.actionExecutor,
required this.entityId,
required this.executorProperty,
});
factory Action.fromRawJson(String str) => Action.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Action.fromJson(Map<String, dynamic> json) => Action(
actionExecutor: json["actionExecutor"],
entityId: json["entityId"],
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
);
Map<String, dynamic> toJson() => {
"actionExecutor": actionExecutor,
"entityId": entityId,
"executorProperty": executorProperty.toJson(),
};
}
class ExecutorProperty {
final String? functionCode;
final dynamic functionValue;
final dynamic delaySeconds;
ExecutorProperty({
this.functionCode,
this.functionValue,
this.delaySeconds,
});
factory ExecutorProperty.fromJson(Map<String, dynamic> json) =>
ExecutorProperty(
functionCode: json["functionCode"] ?? '',
functionValue: json["functionValue"] ?? '',
delaySeconds: json["delaySeconds"] ?? 0,
);
Map<String, dynamic> toJson() => {
"functionCode": functionCode,
"functionValue": functionValue,
"delaySeconds": delaySeconds,
};
}