mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Update Automation Status
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/automation_scene_trigger_bloc/automation_status_update.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_scene_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/icon_model.dart';
|
||||
@ -230,4 +231,59 @@ class SceneApi {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> updateAutomationStatus(String automationId,
|
||||
AutomationStatusUpdate createAutomationEnable, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.patch(
|
||||
path: ApiEndpoints.updateAutomationStatus
|
||||
.replaceAll('{automationId}', automationId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
body: createAutomationEnable.toMap(),
|
||||
expectedResponseModel: (json) => json['success'],
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> triggerScene(String sceneId) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.triggerScene.replaceAll('{sceneId}', sceneId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json['success'],
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
static Future<List<ScenesModel>> getAutomationByUnitId(
|
||||
String unitId,
|
||||
String communityId,
|
||||
String projectId,
|
||||
) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUnitAutomation
|
||||
.replaceAll('{unitUuid}', unitId)
|
||||
.replaceAll('{communityId}', communityId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<ScenesModel> scenes = [];
|
||||
for (var scene in json) {
|
||||
scenes.add(ScenesModel.fromJson(scene));
|
||||
}
|
||||
return scenes;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user