updated endpoint for creating automations

This commit is contained in:
hannathkadher
2025-03-14 11:54:47 +04:00
parent 2a0f6a4596
commit 7ae3e4a933
3 changed files with 7 additions and 5 deletions

View File

@ -324,6 +324,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
Future<void> _onCreateAutomation(CreateAutomationEvent event, Emitter<RoutineState> emit) async { Future<void> _onCreateAutomation(CreateAutomationEvent event, Emitter<RoutineState> emit) async {
try { try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
if (state.routineName == null || state.routineName!.isEmpty) { if (state.routineName == null || state.routineName!.isEmpty) {
emit(state.copyWith( emit(state.copyWith(
errorMessage: 'Automation name is required', errorMessage: 'Automation name is required',
@ -434,7 +436,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
actions: actions, actions: actions,
); );
final result = await SceneApi.createAutomation(createAutomationModel); final result = await SceneApi.createAutomation(createAutomationModel, projectUuid);
if (result['success']) { if (result['success']) {
add(ResetRoutineState()); add(ResetRoutineState());
add(const LoadAutomation()); add(const LoadAutomation());

View File

@ -33,10 +33,10 @@ 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) {

View File

@ -69,10 +69,10 @@ abstract class ApiEndpoints {
//product //product
static const String listProducts = '/products'; static const String listProducts = '/products';
static const String getSpaceScenes = '/scene/tap-to-run/{spaceUuid}'; 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 getIconScene = '/scene/icon';
static const String createScene = '/scene/tap-to-run'; static const String createScene = '/scene/tap-to-run';
static const String createAutomation = '/automation'; static const String createAutomation = '/projects/{projectId}/automations';
static const String getUnitScenes = static const String getUnitScenes =
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/scenes'; '/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
static const String getAutomationDetails = '/automation/details/{automationId}'; static const String getAutomationDetails = '/automation/details/{automationId}';