mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-11 07:37:48 +00:00
43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
|
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/room_model.dart';
|
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
|
import 'package:syncrow_app/services/api/http_service.dart';
|
|
|
|
class SpacesAPI {
|
|
static final HTTPService _httpService = HTTPService();
|
|
|
|
static Future<List<SpaceModel>> getSpaces() async {
|
|
var uuid =
|
|
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
|
final response = await _httpService.get(
|
|
path: ApiEndpoints.spaces,
|
|
queryParameters: {
|
|
"userUuid": uuid,
|
|
},
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) => SpaceModel.fromJsonList(json),
|
|
);
|
|
return response;
|
|
}
|
|
|
|
//get rooms by space id
|
|
static Future<List<RoomModel>> getRoomsBySpaceId(int spaceId) async {
|
|
final response = await _httpService.get(
|
|
path: ApiEndpoints.rooms,
|
|
queryParameters: {"homeId": spaceId},
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) {
|
|
List<RoomModel> rooms = [];
|
|
for (var room in json) {
|
|
rooms.add(RoomModel.fromJson(room));
|
|
}
|
|
return rooms;
|
|
},
|
|
);
|
|
return response;
|
|
}
|
|
}
|