mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
updated endpoint for creating automations
This commit is contained in:
@ -324,6 +324,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
|
||||
Future<void> _onCreateAutomation(CreateAutomationEvent event, Emitter<RoutineState> emit) async {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||
emit(state.copyWith(
|
||||
errorMessage: 'Automation name is required',
|
||||
@ -434,7 +436,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
actions: actions,
|
||||
);
|
||||
|
||||
final result = await SceneApi.createAutomation(createAutomationModel);
|
||||
final result = await SceneApi.createAutomation(createAutomationModel, projectUuid);
|
||||
if (result['success']) {
|
||||
add(ResetRoutineState());
|
||||
add(const LoadAutomation());
|
||||
|
@ -33,10 +33,10 @@ class SceneApi {
|
||||
//
|
||||
// create automation
|
||||
static Future<Map<String, dynamic>> createAutomation(
|
||||
CreateAutomationModel createAutomationModel) async {
|
||||
CreateAutomationModel createAutomationModel, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.createAutomation,
|
||||
path: ApiEndpoints.createAutomation.replaceAll('{projectId}', projectId),
|
||||
body: createAutomationModel.toMap(),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
|
@ -69,10 +69,10 @@ 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 = '/automation';
|
||||
static const String createAutomation = '/projects/{projectId}/automations';
|
||||
static const String getUnitScenes =
|
||||
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
|
||||
static const String getAutomationDetails = '/automation/details/{automationId}';
|
||||
|
Reference in New Issue
Block a user