feat: ignis app v1.0.0 -- управление WiZ лампами
This commit is contained in:
38
lib/models/home_config.dart
Normal file
38
lib/models/home_config.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
/// Модель "дома" -- один физический сервер Ignis.
|
||||
/// Каждый дом имеет свой URL и API-ключ.
|
||||
class HomeConfig {
|
||||
final String id; // уникальный идентификатор (uuid или timestamp)
|
||||
final String name; // человекочитаемое название ("Квартира", "Дача")
|
||||
final String url; // адрес сервера (например ignis.akokos.ru)
|
||||
final String apiKey; // ключ авторизации
|
||||
|
||||
HomeConfig({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.url,
|
||||
required this.apiKey,
|
||||
});
|
||||
|
||||
/// Сериализация в JSON для хранения в SharedPreferences
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'url': url,
|
||||
'apiKey': apiKey,
|
||||
};
|
||||
|
||||
factory HomeConfig.fromJson(Map<String, dynamic> json) => HomeConfig(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
url: json['url'] as String,
|
||||
apiKey: json['apiKey'] as String,
|
||||
);
|
||||
|
||||
/// Копирование с изменениями
|
||||
HomeConfig copyWith({String? name, String? url, String? apiKey}) => HomeConfig(
|
||||
id: id,
|
||||
name: name ?? this.name,
|
||||
url: url ?? this.url,
|
||||
apiKey: apiKey ?? this.apiKey,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user