mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
updated delete endpoint for automation
This commit is contained in:
@ -360,8 +360,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
response = event.updateScene
|
response = event.updateScene
|
||||||
? await SceneApi.updateAutomation(event.createAutomationModel!,
|
? await SceneApi.updateAutomation(event.createAutomationModel!,
|
||||||
event.sceneId, project?.uuid ?? '')
|
event.sceneId, project?.uuid ?? '')
|
||||||
: await SceneApi.createAutomation(event.createAutomationModel!,
|
: await SceneApi.createAutomation(
|
||||||
project?.uuid ?? '');
|
event.createAutomationModel!, project?.uuid ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response['success'] == true) {
|
if (response['success'] == true) {
|
||||||
@ -613,10 +613,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(DeleteSceneLoading());
|
emit(DeleteSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
final response =
|
final response =
|
||||||
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
||||||
? await SceneApi.deleteAutomation(
|
? await SceneApi.deleteAutomation(
|
||||||
automationId: event.sceneId, unitUuid: event.unitUuid)
|
automationId: event.sceneId,
|
||||||
|
unitUuid: event.unitUuid,
|
||||||
|
projectId: project?.uuid ?? '')
|
||||||
: await SceneApi.deleteScene(
|
: await SceneApi.deleteScene(
|
||||||
sceneId: event.sceneId,
|
sceneId: event.sceneId,
|
||||||
);
|
);
|
||||||
|
@ -102,13 +102,14 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
|||||||
Project? project = HomeCubit.getInstance().project;
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
final success = await SceneApi.updateAutomationStatus(
|
final success = await SceneApi.updateAutomationStatus(
|
||||||
event.automationId, event.automationStatusUpdate);
|
event.automationId,
|
||||||
|
event.automationStatusUpdate,
|
||||||
|
project?.uuid ?? '');
|
||||||
if (success) {
|
if (success) {
|
||||||
automationList = await SceneApi.getAutomationByUnitId(
|
automationList = await SceneApi.getAutomationByUnitId(
|
||||||
event.automationStatusUpdate.spaceUuid,
|
event.automationStatusUpdate.spaceUuid,
|
||||||
event.communityId,
|
event.communityId,
|
||||||
project?.uuid ?? ''
|
project?.uuid ?? '');
|
||||||
);
|
|
||||||
newLoadingStates[event.automationId] = false;
|
newLoadingStates[event.automationId] = false;
|
||||||
emit(SceneLoaded(
|
emit(SceneLoaded(
|
||||||
currentState.scenes,
|
currentState.scenes,
|
||||||
|
@ -164,12 +164,12 @@ abstract class ApiEndpoints {
|
|||||||
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
|
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
static const String updateAutomationStatus =
|
static const String updateAutomationStatus =
|
||||||
'/automation/status/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
/// DELETE
|
/// DELETE
|
||||||
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String deleteAutomation = '/automation/{automationId}';
|
static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
//////////////////////Door Lock //////////////////////
|
//////////////////////Door Lock //////////////////////
|
||||||
//online
|
//online
|
||||||
|
@ -136,11 +136,12 @@ class SceneApi {
|
|||||||
|
|
||||||
//updateAutomationStatus
|
//updateAutomationStatus
|
||||||
static Future<bool> updateAutomationStatus(String automationId,
|
static Future<bool> updateAutomationStatus(String automationId,
|
||||||
AutomationStatusUpdate createAutomationEnable) async {
|
AutomationStatusUpdate createAutomationEnable, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.patch(
|
||||||
path: ApiEndpoints.updateAutomationStatus
|
path: ApiEndpoints.updateAutomationStatus
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationEnable.toMap(),
|
body: createAutomationEnable.toMap(),
|
||||||
expectedResponseModel: (json) => json['success'],
|
expectedResponseModel: (json) => json['success'],
|
||||||
);
|
);
|
||||||
@ -238,11 +239,14 @@ class SceneApi {
|
|||||||
|
|
||||||
// delete automation
|
// delete automation
|
||||||
static Future<bool> deleteAutomation(
|
static Future<bool> deleteAutomation(
|
||||||
{required String unitUuid, required String automationId}) async {
|
{required String unitUuid,
|
||||||
|
required String automationId,
|
||||||
|
required String projectId}) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.delete(
|
final response = await _httpService.delete(
|
||||||
path: ApiEndpoints.deleteAutomation
|
path: ApiEndpoints.deleteAutomation
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => json['statusCode'] == 200,
|
expectedResponseModel: (json) => json['statusCode'] == 200,
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user