mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
updated endpoint for update automation
This commit is contained in:
@ -15,7 +15,6 @@ import 'package:syncrow_app/features/scene/model/icon_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
import 'package:syncrow_app/utils/constants/temp_const.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
part 'create_scene_event.dart';
|
||||
@ -359,10 +358,10 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
: await SceneApi.createScene(event.createSceneModel!);
|
||||
} else if (event.createAutomationModel != null) {
|
||||
response = event.updateScene
|
||||
? await SceneApi.updateAutomation(
|
||||
event.createAutomationModel!, event.sceneId)
|
||||
? await SceneApi.updateAutomation(event.createAutomationModel!,
|
||||
event.sceneId, project?.uuid ?? '')
|
||||
: await SceneApi.createAutomation(event.createAutomationModel!,
|
||||
project?.uuid ?? TempConst.projectIdDev);
|
||||
project?.uuid ?? '');
|
||||
}
|
||||
|
||||
if (response['success'] == true) {
|
||||
@ -444,7 +443,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
conditionRule = 'or';
|
||||
|
||||
final response = event.isAutomation
|
||||
? await SceneApi.getAutomationDetails(event.sceneId, project?.uuid ?? '')
|
||||
? await SceneApi.getAutomationDetails(
|
||||
event.sceneId, project?.uuid ?? '')
|
||||
: await SceneApi.getSceneDetails(event.sceneId);
|
||||
if (response.id.isNotEmpty) {
|
||||
if (event.isAutomation) {
|
||||
|
@ -161,7 +161,7 @@ abstract class ApiEndpoints {
|
||||
/// PUT
|
||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
||||
|
||||
static const String updateAutomation = '/automation/{automationId}';
|
||||
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
|
||||
|
||||
static const String updateAutomationStatus =
|
||||
'/automation/status/{automationId}';
|
||||
|
@ -202,12 +202,13 @@ class SceneApi {
|
||||
}
|
||||
|
||||
//update automation
|
||||
static updateAutomation(
|
||||
CreateAutomationModel createAutomationModel, String automationId) async {
|
||||
static updateAutomation(CreateAutomationModel createAutomationModel,
|
||||
String automationId, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.updateAutomation
|
||||
.replaceAll('{automationId}', automationId),
|
||||
.replaceAll('{automationId}', automationId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
body: createAutomationModel
|
||||
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||
expectedResponseModel: (json) {
|
||||
|
Reference in New Issue
Block a user