mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +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 {
|
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());
|
||||||
|
@ -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) {
|
||||||
|
@ -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}';
|
||||||
|
Reference in New Issue
Block a user