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/features/scene/model/scene_static_function.dart';
|
||||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||||
import 'package:syncrow_app/services/api/scene_api.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';
|
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||||
|
|
||||||
part 'create_scene_event.dart';
|
part 'create_scene_event.dart';
|
||||||
@ -359,10 +358,10 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
: await SceneApi.createScene(event.createSceneModel!);
|
: await SceneApi.createScene(event.createSceneModel!);
|
||||||
} else if (event.createAutomationModel != null) {
|
} else if (event.createAutomationModel != null) {
|
||||||
response = event.updateScene
|
response = event.updateScene
|
||||||
? await SceneApi.updateAutomation(
|
? await SceneApi.updateAutomation(event.createAutomationModel!,
|
||||||
event.createAutomationModel!, event.sceneId)
|
event.sceneId, project?.uuid ?? '')
|
||||||
: await SceneApi.createAutomation(event.createAutomationModel!,
|
: await SceneApi.createAutomation(event.createAutomationModel!,
|
||||||
project?.uuid ?? TempConst.projectIdDev);
|
project?.uuid ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response['success'] == true) {
|
if (response['success'] == true) {
|
||||||
@ -427,7 +426,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Project? project = HomeCubit.getInstance().project;
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
tasksList.clear();
|
tasksList.clear();
|
||||||
tempTasksList.clear();
|
tempTasksList.clear();
|
||||||
@ -444,7 +443,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
conditionRule = 'or';
|
conditionRule = 'or';
|
||||||
|
|
||||||
final response = event.isAutomation
|
final response = event.isAutomation
|
||||||
? await SceneApi.getAutomationDetails(event.sceneId, project?.uuid ?? '')
|
? await SceneApi.getAutomationDetails(
|
||||||
|
event.sceneId, project?.uuid ?? '')
|
||||||
: await SceneApi.getSceneDetails(event.sceneId);
|
: await SceneApi.getSceneDetails(event.sceneId);
|
||||||
if (response.id.isNotEmpty) {
|
if (response.id.isNotEmpty) {
|
||||||
if (event.isAutomation) {
|
if (event.isAutomation) {
|
||||||
|
@ -161,7 +161,7 @@ abstract class ApiEndpoints {
|
|||||||
/// PUT
|
/// PUT
|
||||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
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 =
|
static const String updateAutomationStatus =
|
||||||
'/automation/status/{automationId}';
|
'/automation/status/{automationId}';
|
||||||
|
@ -202,12 +202,13 @@ class SceneApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//update automation
|
//update automation
|
||||||
static updateAutomation(
|
static updateAutomation(CreateAutomationModel createAutomationModel,
|
||||||
CreateAutomationModel createAutomationModel, String automationId) async {
|
String automationId, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.put(
|
||||||
path: ApiEndpoints.updateAutomation
|
path: ApiEndpoints.updateAutomation
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationModel
|
body: createAutomationModel
|
||||||
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
|
Reference in New Issue
Block a user