mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 09:34:54 +00:00
Merge pull request #75 from SyncrowIOT/SP-1245
updated endpoint for automation
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/auth/model/project_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_event.dart';
|
||||||
@ -348,15 +350,18 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
try {
|
try {
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
if (event.createSceneModel != null) {
|
if (event.createSceneModel != null) {
|
||||||
response = event.updateScene
|
response = event.updateScene
|
||||||
? await SceneApi.updateScene(event.createSceneModel!, event.sceneId)
|
? await SceneApi.updateScene(event.createSceneModel!, event.sceneId)
|
||||||
: 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 ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response['success'] == true) {
|
if (response['success'] == true) {
|
||||||
@ -421,6 +426,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
tasksList.clear();
|
tasksList.clear();
|
||||||
tempTasksList.clear();
|
tempTasksList.clear();
|
||||||
selectedValues.clear();
|
selectedValues.clear();
|
||||||
@ -436,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)
|
? 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) {
|
||||||
@ -605,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,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -46,8 +46,11 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
|||||||
emit(SceneLoading());
|
emit(SceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
if (event.unitId.isNotEmpty) {
|
if (event.unitId.isNotEmpty) {
|
||||||
automationList = await SceneApi.getAutomationByUnitId(event.unitId);
|
automationList = await SceneApi.getAutomationByUnitId(
|
||||||
|
event.unitId, event.communityId, project?.uuid ?? '');
|
||||||
emit(SceneLoaded(scenes, automationList));
|
emit(SceneLoaded(scenes, automationList));
|
||||||
} else {
|
} else {
|
||||||
emit(const SceneError(message: 'Unit ID is empty'));
|
emit(const SceneError(message: 'Unit ID is empty'));
|
||||||
@ -96,11 +99,17 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
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,
|
||||||
|
project?.uuid ?? '');
|
||||||
newLoadingStates[event.automationId] = false;
|
newLoadingStates[event.automationId] = false;
|
||||||
emit(SceneLoaded(
|
emit(SceneLoaded(
|
||||||
currentState.scenes,
|
currentState.scenes,
|
||||||
|
|||||||
@ -22,11 +22,13 @@ class LoadScenes extends SceneEvent {
|
|||||||
|
|
||||||
class LoadAutomation extends SceneEvent {
|
class LoadAutomation extends SceneEvent {
|
||||||
final String unitId;
|
final String unitId;
|
||||||
|
final String communityId;
|
||||||
|
|
||||||
const LoadAutomation(this.unitId);
|
|
||||||
|
const LoadAutomation(this.unitId, this.communityId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [unitId];
|
List<Object> get props => [unitId, communityId];
|
||||||
}
|
}
|
||||||
|
|
||||||
class SceneTrigger extends SceneEvent {
|
class SceneTrigger extends SceneEvent {
|
||||||
@ -43,8 +45,9 @@ class SceneTrigger extends SceneEvent {
|
|||||||
class UpdateAutomationStatus extends SceneEvent {
|
class UpdateAutomationStatus extends SceneEvent {
|
||||||
final String automationId;
|
final String automationId;
|
||||||
final AutomationStatusUpdate automationStatusUpdate;
|
final AutomationStatusUpdate automationStatusUpdate;
|
||||||
|
final String communityId;
|
||||||
|
|
||||||
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId});
|
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId, required this.communityId});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [automationStatusUpdate];
|
List<Object> get props => [automationStatusUpdate];
|
||||||
|
|||||||
@ -49,7 +49,9 @@ class SceneView extends StatelessWidget {
|
|||||||
name: '',
|
name: '',
|
||||||
)),
|
)),
|
||||||
showInDevice: pageType))
|
showInDevice: pageType))
|
||||||
..add(LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? ''));
|
..add(LoadAutomation(
|
||||||
|
HomeCubit.getInstance().selectedSpace?.id ?? '',
|
||||||
|
HomeCubit.getInstance().selectedSpace?.community.uuid ?? ''));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||||
@ -57,30 +59,37 @@ class SceneView extends StatelessWidget {
|
|||||||
if (state is DeleteSceneSuccess) {
|
if (state is DeleteSceneSuccess) {
|
||||||
if (state.success) {
|
if (state.success) {
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
||||||
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!,
|
HomeCubit.getInstance().selectedSpace!.id,
|
||||||
|
HomeCubit.getInstance().selectedSpace!,
|
||||||
showInDevice: pageType));
|
showInDevice: pageType));
|
||||||
BlocProvider.of<SceneBloc>(context)
|
BlocProvider.of<SceneBloc>(context).add(LoadAutomation(
|
||||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
|
HomeCubit.getInstance().selectedSpace!.id,
|
||||||
|
HomeCubit.getInstance().selectedSpace!.community.uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state is CreateSceneWithTasks) {
|
if (state is CreateSceneWithTasks) {
|
||||||
if (state.success == true) {
|
if (state.success == true) {
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
||||||
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!,
|
HomeCubit.getInstance().selectedSpace!.id,
|
||||||
|
HomeCubit.getInstance().selectedSpace!,
|
||||||
showInDevice: pageType));
|
showInDevice: pageType));
|
||||||
BlocProvider.of<SceneBloc>(context)
|
BlocProvider.of<SceneBloc>(context).add(LoadAutomation(
|
||||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
|
HomeCubit.getInstance().selectedSpace!.id,
|
||||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
HomeCubit.getInstance().selectedSpace!.community.uuid));
|
||||||
|
context
|
||||||
|
.read<SmartSceneSelectBloc>()
|
||||||
|
.add(const SmartSceneClearEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BlocListener<SceneBloc, SceneState>(
|
return BlocListener<SceneBloc, SceneState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is SceneTriggerSuccess) {
|
if (state is SceneTriggerSuccess) {
|
||||||
context.showCustomSnackbar(
|
context.showCustomSnackbar(
|
||||||
message: 'Scene ${state.sceneName} triggered successfully!');
|
message:
|
||||||
|
'Scene ${state.sceneName} triggered successfully!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: HomeCubit.getInstance().spaces?.isEmpty ?? true
|
child: HomeCubit.getInstance().spaces.isEmpty
|
||||||
? const CreateUnitWidget()
|
? const CreateUnitWidget()
|
||||||
: Column(
|
: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -114,25 +123,30 @@ class SceneView extends StatelessWidget {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
Theme(
|
Theme(
|
||||||
data: ThemeData()
|
data: ThemeData().copyWith(
|
||||||
.copyWith(dividerColor: Colors.transparent),
|
dividerColor: Colors.transparent),
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
tilePadding: const EdgeInsets.symmetric(horizontal: 6),
|
tilePadding:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6),
|
||||||
initiallyExpanded: true,
|
initiallyExpanded: true,
|
||||||
iconColor: ColorsManager.grayColor,
|
iconColor: ColorsManager.grayColor,
|
||||||
title: const BodyMedium(text: 'Tap to run routines'),
|
title: const BodyMedium(
|
||||||
|
text: 'Tap to run routines'),
|
||||||
children: [
|
children: [
|
||||||
scenes.isNotEmpty
|
scenes.isNotEmpty
|
||||||
? SceneGrid(
|
? SceneGrid(
|
||||||
scenes: scenes,
|
scenes: scenes,
|
||||||
loadingSceneId: state.loadingSceneId,
|
loadingSceneId:
|
||||||
|
state.loadingSceneId,
|
||||||
disablePlayButton: false,
|
disablePlayButton: false,
|
||||||
loadingStates:
|
loadingStates: state
|
||||||
state.loadingStates, // Add this line
|
.loadingStates, // Add this line
|
||||||
)
|
)
|
||||||
: const Center(
|
: const Center(
|
||||||
child: BodyMedium(
|
child: BodyMedium(
|
||||||
text: 'No scenes have been added yet',
|
text:
|
||||||
|
'No scenes have been added yet',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@ -142,25 +156,30 @@ class SceneView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Theme(
|
Theme(
|
||||||
data: ThemeData()
|
data: ThemeData().copyWith(
|
||||||
.copyWith(dividerColor: Colors.transparent),
|
dividerColor: Colors.transparent),
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
initiallyExpanded: true,
|
initiallyExpanded: true,
|
||||||
iconColor: ColorsManager.grayColor,
|
iconColor: ColorsManager.grayColor,
|
||||||
tilePadding: const EdgeInsets.symmetric(horizontal: 6),
|
tilePadding:
|
||||||
title: const BodyMedium(text: 'Automation'),
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6),
|
||||||
|
title: const BodyMedium(
|
||||||
|
text: 'Automation'),
|
||||||
children: [
|
children: [
|
||||||
automationList.isNotEmpty
|
automationList.isNotEmpty
|
||||||
? SceneGrid(
|
? SceneGrid(
|
||||||
scenes: automationList,
|
scenes: automationList,
|
||||||
loadingSceneId: state.loadingSceneId,
|
loadingSceneId:
|
||||||
|
state.loadingSceneId,
|
||||||
disablePlayButton: true,
|
disablePlayButton: true,
|
||||||
loadingStates:
|
loadingStates: state
|
||||||
state.loadingStates, // Add this line
|
.loadingStates, // Add this line
|
||||||
)
|
)
|
||||||
: const Center(
|
: const Center(
|
||||||
child: BodyMedium(
|
child: BodyMedium(
|
||||||
text: 'No automations have been added yet',
|
text:
|
||||||
|
'No automations have been added yet',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class DeleteRoutineButton extends StatelessWidget {
|
|||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
||||||
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!));
|
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!));
|
||||||
BlocProvider.of<SceneBloc>(context)
|
BlocProvider.of<SceneBloc>(context)
|
||||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
|
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id,HomeCubit.getInstance().selectedSpace!.community.uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -132,6 +132,10 @@ class SceneItem extends StatelessWidget {
|
|||||||
spaceUuid: HomeCubit.getInstance()
|
spaceUuid: HomeCubit.getInstance()
|
||||||
.selectedSpace!
|
.selectedSpace!
|
||||||
.id),
|
.id),
|
||||||
|
communityId: HomeCubit.getInstance()
|
||||||
|
.selectedSpace!
|
||||||
|
.community
|
||||||
|
.uuid,
|
||||||
automationId: scene.id));
|
automationId: scene.id));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class SmartEnableAutomation extends StatelessWidget {
|
|||||||
child: BlocBuilder<SceneBloc, SceneState>(
|
child: BlocBuilder<SceneBloc, SceneState>(
|
||||||
bloc: context.read<SceneBloc>()
|
bloc: context.read<SceneBloc>()
|
||||||
..add(
|
..add(
|
||||||
LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '')),
|
LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '',HomeCubit.getInstance().selectedSpace?.community.uuid ?? '')),
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is SceneLoading) {
|
if (state is SceneLoading) {
|
||||||
return const Align(
|
return const Align(
|
||||||
|
|||||||
@ -144,7 +144,7 @@ abstract class ApiEndpoints {
|
|||||||
/// POST
|
/// POST
|
||||||
static const String createScene = '/scene/tap-to-run';
|
static const String createScene = '/scene/tap-to-run';
|
||||||
static const String triggerScene = '/scene/tap-to-run/{sceneId}/trigger';
|
static const String triggerScene = '/scene/tap-to-run/{sceneId}/trigger';
|
||||||
static const String createAutomation = '/automation';
|
static const String createAutomation = '/projects/{projectId}/automations';
|
||||||
|
|
||||||
/// GET
|
/// GET
|
||||||
static const String getUnitScenes =
|
static const String getUnitScenes =
|
||||||
@ -153,23 +153,23 @@ abstract class ApiEndpoints {
|
|||||||
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
||||||
static const String getIconScene = '/scene/icon';
|
static const String getIconScene = '/scene/icon';
|
||||||
|
|
||||||
static const String getUnitAutomation = '/automation/{unitUuid}';
|
static const String getUnitAutomation = '/projects/{projectId}/communities/{communityId}/spaces/{unitUuid}/automations';
|
||||||
|
|
||||||
static const String getAutomationDetails =
|
static const String getAutomationDetails =
|
||||||
'/automation/details/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
/// 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}';
|
'/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
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
|||||||
import 'package:syncrow_app/features/scene/model/update_automation.dart';
|
import 'package:syncrow_app/features/scene/model/update_automation.dart';
|
||||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||||
import 'package:syncrow_app/services/api/http_service.dart';
|
import 'package:syncrow_app/services/api/http_service.dart';
|
||||||
import 'package:syncrow_app/utils/constants/temp_const.dart';
|
|
||||||
|
|
||||||
class SceneApi {
|
class SceneApi {
|
||||||
static final HTTPService _httpService = HTTPService();
|
static final HTTPService _httpService = HTTPService();
|
||||||
@ -31,10 +30,11 @@ class SceneApi {
|
|||||||
|
|
||||||
// create automation
|
// create automation
|
||||||
static Future<Map<String, dynamic>> createAutomation(
|
static Future<Map<String, dynamic>> createAutomation(
|
||||||
CreateAutomationModel createAutomationModel) async {
|
CreateAutomationModel createAutomationModel, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.createAutomation,
|
path:
|
||||||
|
ApiEndpoints.createAutomation.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationModel.toMap(),
|
body: createAutomationModel.toMap(),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
@ -78,10 +78,17 @@ class SceneApi {
|
|||||||
|
|
||||||
//getAutomation
|
//getAutomation
|
||||||
|
|
||||||
static Future<List<ScenesModel>> getAutomationByUnitId(String unitId) async {
|
static Future<List<ScenesModel>> getAutomationByUnitId(
|
||||||
|
String unitId,
|
||||||
|
String communityId,
|
||||||
|
String projectId,
|
||||||
|
) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.getUnitAutomation.replaceAll('{unitUuid}', unitId),
|
path: ApiEndpoints.getUnitAutomation
|
||||||
|
.replaceAll('{unitUuid}', unitId)
|
||||||
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<ScenesModel> scenes = [];
|
List<ScenesModel> scenes = [];
|
||||||
@ -112,11 +119,12 @@ class SceneApi {
|
|||||||
|
|
||||||
//automation details
|
//automation details
|
||||||
static Future<SceneDetailsModel> getAutomationDetails(
|
static Future<SceneDetailsModel> getAutomationDetails(
|
||||||
String automationId) async {
|
String automationId, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.getAutomationDetails
|
path: ApiEndpoints.getAutomationDetails
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
||||||
);
|
);
|
||||||
@ -128,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'],
|
||||||
);
|
);
|
||||||
@ -194,12 +203,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) {
|
||||||
@ -229,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