changed endpoint for automation update

This commit is contained in:
hannathkadher
2025-03-14 12:16:32 +04:00
parent bc64efa557
commit e0486deecb
3 changed files with 15 additions and 7 deletions

View File

@ -808,7 +808,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? '');
} else {
await SceneApi.deleteAutomation(
unitUuid: spaceBloc.state.selectedSpaces[0], automationId: state.automationId ?? '',projectId: projectId);
unitUuid: spaceBloc.state.selectedSpaces[0],
automationId: state.automationId ?? '',
projectId: projectId);
}
add(const LoadScenes());
@ -948,6 +950,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
FutureOr<void> _onUpdateAutomation(UpdateAutomation event, Emitter<RoutineState> emit) async {
try {
final projectId = await ProjectManager.getProjectUUID() ?? '';
if (state.routineName == null || state.routineName!.isEmpty) {
emit(state.copyWith(
errorMessage: 'Automation name is required',
@ -1057,8 +1061,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
actions: actions,
);
final result =
await SceneApi.updateAutomation(createAutomationModel, state.automationId ?? '');
final result = await SceneApi.updateAutomation(
createAutomationModel, state.automationId ?? '', projectId);
if (result['success']) {
add(ResetRoutineState());

View File

@ -166,10 +166,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),
path: ApiEndpoints.updateAutomation
.replaceAll('{automationId}', automationId)
.replaceAll('{projectId}', projectId),
body: createAutomationModel.toJson(automationId.isNotEmpty == true ? automationId : null),
expectedResponseModel: (json) {
return json;

View File

@ -69,7 +69,8 @@ abstract class ApiEndpoints {
//product
static const String listProducts = '/products';
static const String getSpaceScenes = '/scene/tap-to-run/{spaceUuid}';
static const String getSpaceAutomation = '/projects/{projectId}/communities/{communityId}/spaces/{spaceUuid}/automations';
static const String getSpaceAutomation =
'/projects/{projectId}/communities/{communityId}/spaces/{spaceUuid}/automations';
static const String getIconScene = '/scene/icon';
static const String createScene = '/scene/tap-to-run';
static const String createAutomation = '/projects/{projectId}/automations';
@ -82,7 +83,7 @@ abstract class ApiEndpoints {
static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
static const String updateScene = '/scene/tap-to-run/{sceneId}';
static const String updateAutomation = '/automation/{automationId}';
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
//space model
static const String listSpaceModels = '/projects/{projectId}/space-models';