updated endpoint for update automation

This commit is contained in:
hannathkadher
2025-03-14 12:58:12 +04:00
parent 88aac86b10
commit 0d50aa68fa
3 changed files with 11 additions and 10 deletions

View File

@ -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) {

View File

@ -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}';

View File

@ -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) {