Merge pull request #65 from SyncrowIOT/feat/change-community-endpoint

changed endpoint
This commit is contained in:
hannathkadher
2024-12-11 16:17:20 +04:00
committed by GitHub
7 changed files with 31 additions and 17 deletions

View File

@ -59,11 +59,11 @@ abstract class ApiEndpoints {
//GET //GET
static const String unitByUuid = '/unit/'; static const String unitByUuid = '/unit/';
static const String listSubspace = 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 unitParent = '/unit/parent/{unitUuid}';
static const String unitUser = '/unit/user/'; static const String unitUser = '/unit/user/';
static const String invitationCode = static const String invitationCode =
'/communities/{communityUuid}/spaces/{unitUuid}/invitation-code'; 'projects/{projectUuid}/communities/{communityUuid}/spaces/{unitUuid}/invitation-code';
//PUT //PUT
static const String renameUnit = '/unit/{unitUuid}'; static const String renameUnit = '/unit/{unitUuid}';
@ -71,7 +71,7 @@ abstract class ApiEndpoints {
//Subspace Module //Subspace Module
//POST //POST
static const String addSubSpace = static const String addSubSpace =
'/communities/{communityUuid}/spaces/{spaceUuid}/subspaces'; 'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces';
///Room Module ///Room Module
//POST //POST
@ -88,7 +88,7 @@ abstract class ApiEndpoints {
//GET //GET
static const String userSpaces = '/user/{userUuid}/spaces'; static const String userSpaces = '/user/{userUuid}/spaces';
static const String spaceDevices = static const String spaceDevices =
'/communities/{communityUuid}/spaces/{spaceUuid}/devices'; 'projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
///Group Module ///Group Module
//POST //POST
@ -117,7 +117,7 @@ abstract class ApiEndpoints {
//GET //GET
static const String deviceByRoom = 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 deviceByUuid = '/device/{deviceUuid}';
static const String deviceFunctions = '/device/{deviceUuid}/functions'; static const String deviceFunctions = '/device/{deviceUuid}/functions';
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices'; 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 editDevicePermission = '/device-permission/edit/{userId}';
static const String assignDeviceToRoom = 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 //////////////////// /// Scene & Automation API ////////////////////
/// POST /// POST
@ -145,7 +145,7 @@ abstract class ApiEndpoints {
/// GET /// GET
static const String getUnitScenes = 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 getScene = '/scene/tap-to-run/{sceneId}';
static const String getIconScene = '/scene/icon'; 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/features/devices/model/function_model.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';
import '../../features/devices/model/create_temporary_password_model.dart'; import '../../features/devices/model/create_temporary_password_model.dart';
class DevicesAPI { class DevicesAPI {
@ -224,7 +225,8 @@ class DevicesAPI {
final String path = ApiEndpoints.deviceByRoom final String path = ApiEndpoints.deviceByRoom
.replaceAll('{communityUuid}', communityUuid) .replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid) .replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{subSpaceUuid}', roomId); .replaceAll('{subSpaceUuid}', roomId)
.replaceAll('{projectUuid}', TempConst.projectId);
final response = await _httpService.get( final response = await _httpService.get(
path: path, path: path,

View File

@ -1,5 +1,6 @@
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 HomeCreation { class HomeCreation {
static final HTTPService _httpService = HTTPService(); static final HTTPService _httpService = HTTPService();
@ -148,7 +149,8 @@ class HomeCreation {
try { try {
final fullPath = ApiEndpoints.addSubSpace final fullPath = ApiEndpoints.addSubSpace
.replaceAll('{communityUuid}', communityId) .replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId); .replaceAll('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectId);
final response = await _httpService.post( final response = await _httpService.post(
path: fullPath, path: fullPath,
body: body, 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/features/devices/model/device_model.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 HomeManagementAPI { class HomeManagementAPI {
static final HTTPService _httpService = HTTPService(); static final HTTPService _httpService = HTTPService();
@ -38,7 +39,9 @@ class HomeManagementAPI {
// Ensure both placeholders are replaced // Ensure both placeholders are replaced
final path = ApiEndpoints.spaceDevices final path = ApiEndpoints.spaceDevices
.replaceAll('{communityUuid}', communityUuid) .replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid); .replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{projectUuid}', TempConst.projectId);
await _httpService.get( await _httpService.get(
path: path, path: path,
showServerMessage: false, 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 { String spaceId, String subSpaceId, String deviceId) async {
try { try {
final response = await _httpService.delete( final response = await _httpService.delete(
@ -86,7 +89,8 @@ class HomeManagementAPI {
.replaceAll('{communityUuid}', communityId) .replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId) .replaceAll('{spaceUuid}', spaceId)
.replaceAll('{subSpaceUuid}', subSpaceId) .replaceAll('{subSpaceUuid}', subSpaceId)
.replaceAll('{deviceUuid}', deviceId), .replaceAll('{deviceUuid}', deviceId)
.replaceAll('{projectUuid}', TempConst.projectId),
expectedResponseModel: (json) { expectedResponseModel: (json) {
return json; return json;
}, },
@ -96,5 +100,4 @@ class HomeManagementAPI {
rethrow; 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_automation_model.dart';
import 'package:syncrow_app/features/scene/model/create_scene_model.dart'; import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
import 'package:syncrow_app/features/scene/model/icon_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/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();
@ -56,7 +56,8 @@ class SceneApi {
final response = await _httpService.get( final response = await _httpService.get(
path: ApiEndpoints.getUnitScenes path: ApiEndpoints.getUnitScenes
.replaceAll('{spaceUuid}', unitId) .replaceAll('{spaceUuid}', unitId)
.replaceAll('{communityUuid}', communityId), .replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectId),
queryParameters: {'showInHomePage': showInDevice}, queryParameters: {'showInHomePage': showInDevice},
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { 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/features/devices/model/subspace_model.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 SpacesAPI { class SpacesAPI {
static final HTTPService _httpService = HTTPService(); static final HTTPService _httpService = HTTPService();
@ -35,7 +36,8 @@ class SpacesAPI {
// Construct the API path // Construct the API path
final path = ApiEndpoints.listSubspace final path = ApiEndpoints.listSubspace
.replaceFirst('{communityUuid}', communityId) .replaceFirst('{communityUuid}', communityId)
.replaceFirst('{spaceUuid}', spaceId); .replaceFirst('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectId);
final response = await _httpService.get( final response = await _httpService.get(
path: path, path: path,
@ -67,7 +69,8 @@ class SpacesAPI {
final response = await _httpService.get( final response = await _httpService.get(
path: ApiEndpoints.invitationCode path: ApiEndpoints.invitationCode
.replaceAll('{unitUuid}', unitId) .replaceAll('{unitUuid}', unitId)
.replaceAll('{communityUuid}', communityId), .replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectId),
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {
if (json != null && json['data'] != null) { if (json != null && json['data'] != null) {

View File

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