changed endpoint

This commit is contained in:
hannathkadher
2024-12-10 10:49:43 +04:00
parent 2ac8128eff
commit 66eadd2567
7 changed files with 31 additions and 17 deletions

View File

@ -59,11 +59,11 @@ abstract class ApiEndpoints {
//GET
static const String unitByUuid = '/unit/';
static const String listSubspace =
'/communities/{communityUuid}/spaces/{spaceUuid}/subspaces';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces';
static const String unitParent = '/unit/parent/{unitUuid}';
static const String unitUser = '/unit/user/';
static const String invitationCode =
'/communities/{communityUuid}/spaces/{unitUuid}/invitation-code';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{unitUuid}/invitation-code';
//PUT
static const String renameUnit = '/unit/{unitUuid}';
@ -71,7 +71,7 @@ abstract class ApiEndpoints {
//Subspace Module
//POST
static const String addSubSpace =
'/communities/{communityUuid}/spaces/{spaceUuid}/subspaces';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces';
///Room Module
//POST
@ -88,7 +88,7 @@ abstract class ApiEndpoints {
//GET
static const String userSpaces = '/user/{userUuid}/spaces';
static const String spaceDevices =
'/communities/{communityUuid}/spaces/{spaceUuid}/devices';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
///Group Module
//POST
@ -117,7 +117,7 @@ abstract class ApiEndpoints {
//GET
static const String deviceByRoom =
'/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
static const String deviceByUuid = '/device/{deviceUuid}';
static const String deviceFunctions = '/device/{deviceUuid}/functions';
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
@ -135,7 +135,7 @@ abstract class ApiEndpoints {
static const String editDevicePermission = '/device-permission/edit/{userId}';
static const String assignDeviceToRoom =
'/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices/{deviceUuid}';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices/{deviceUuid}';
/// Scene & Automation API ////////////////////
/// POST
@ -145,7 +145,7 @@ abstract class ApiEndpoints {
/// GET
static const String getUnitScenes =
'/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
static const String getScene = '/scene/tap-to-run/{sceneId}';
static const String getIconScene = '/scene/icon';

View File

@ -8,6 +8,7 @@ import 'package:syncrow_app/features/devices/model/device_report_model.dart';
import 'package:syncrow_app/features/devices/model/function_model.dart';
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_service.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import '../../features/devices/model/create_temporary_password_model.dart';
class DevicesAPI {
@ -224,7 +225,8 @@ class DevicesAPI {
final String path = ApiEndpoints.deviceByRoom
.replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{subSpaceUuid}', roomId);
.replaceAll('{subSpaceUuid}', roomId)
.replaceAll('{projectUuid}', TempConst.projectId);
final response = await _httpService.get(
path: path,

View File

@ -1,5 +1,6 @@
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_service.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
class HomeCreation {
static final HTTPService _httpService = HTTPService();
@ -148,7 +149,8 @@ class HomeCreation {
try {
final fullPath = ApiEndpoints.addSubSpace
.replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId);
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectId);
final response = await _httpService.post(
path: fullPath,
body: body,

View File

@ -4,6 +4,7 @@ import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_service.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
class HomeManagementAPI {
static final HTTPService _httpService = HTTPService();
@ -38,7 +39,9 @@ class HomeManagementAPI {
// Ensure both placeholders are replaced
final path = ApiEndpoints.spaceDevices
.replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid);
.replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{projectUuid}', TempConst.projectId);
await _httpService.get(
path: path,
showServerMessage: false,
@ -78,7 +81,7 @@ class HomeManagementAPI {
}
}
static Future<Map<String, dynamic>> unAssignDeviceToRoom(String communityId,
static Future<Map<String, dynamic>> unAssignDeviceToRoom(String communityId,
String spaceId, String subSpaceId, String deviceId) async {
try {
final response = await _httpService.delete(
@ -86,7 +89,8 @@ class HomeManagementAPI {
.replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{subSpaceUuid}', subSpaceId)
.replaceAll('{deviceUuid}', deviceId),
.replaceAll('{deviceUuid}', deviceId)
.replaceAll('{projectUuid}', TempConst.projectId),
expectedResponseModel: (json) {
return json;
},
@ -96,5 +100,4 @@ class HomeManagementAPI {
rethrow;
}
}
}

View File

@ -1,4 +1,3 @@
import 'package:syncrow_app/features/scene/model/create_automation_model.dart';
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
import 'package:syncrow_app/features/scene/model/icon_model.dart';
@ -7,6 +6,7 @@ import 'package:syncrow_app/features/scene/model/scenes_model.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/http_service.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
class SceneApi {
static final HTTPService _httpService = HTTPService();
@ -56,7 +56,8 @@ class SceneApi {
final response = await _httpService.get(
path: ApiEndpoints.getUnitScenes
.replaceAll('{spaceUuid}', unitId)
.replaceAll('{communityUuid}', communityId),
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectId),
queryParameters: {'showInHomePage': showInDevice},
showServerMessage: false,
expectedResponseModel: (json) {

View File

@ -4,6 +4,7 @@ import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_service.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
class SpacesAPI {
static final HTTPService _httpService = HTTPService();
@ -35,7 +36,8 @@ class SpacesAPI {
// Construct the API path
final path = ApiEndpoints.listSubspace
.replaceFirst('{communityUuid}', communityId)
.replaceFirst('{spaceUuid}', spaceId);
.replaceFirst('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectId);
final response = await _httpService.get(
path: path,
@ -67,7 +69,8 @@ class SpacesAPI {
final response = await _httpService.get(
path: ApiEndpoints.invitationCode
.replaceAll('{unitUuid}', unitId)
.replaceAll('{communityUuid}', communityId),
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectId),
showServerMessage: false,
expectedResponseModel: (json) {
if (json != null && json['data'] != null) {

View File

@ -0,0 +1,3 @@
class TempConst {
static const projectId = '0e62577c-06fa-41b9-8a92-99a21fbaf51c';
}