mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-10 23:27:22 +00:00
Updated the API Endpoints, API Calls, Data Models and cubits to the lateset changes from the backend
This commit is contained in:
@ -8,29 +8,25 @@ import 'package:syncrow_app/services/api/http_service.dart';
|
||||
class SpacesAPI {
|
||||
static final HTTPService _httpService = HTTPService();
|
||||
|
||||
static Future<List<SpaceModel>> getSpaces() async {
|
||||
static Future<List<SpaceModel>> getUnitsByUserId() async {
|
||||
var uuid =
|
||||
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.spaces,
|
||||
queryParameters: {
|
||||
"userUuid": uuid,
|
||||
},
|
||||
path: "${ApiEndpoints.unitUser}$uuid",
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => SpaceModel.fromJsonList(json),
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
//get rooms by space id
|
||||
static Future<List<RoomModel>> getRoomsBySpaceId(int spaceId) async {
|
||||
static Future<List<RoomModel>> getRoomsBySpaceId(String unitId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.rooms,
|
||||
queryParameters: {"homeId": spaceId},
|
||||
path: "${ApiEndpoints.unitChild}$unitId",
|
||||
queryParameters: {"page": 1, "pageSize": 10},
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<RoomModel> rooms = [];
|
||||
for (var room in json) {
|
||||
for (var room in json['children']) {
|
||||
rooms.add(RoomModel.fromJson(room));
|
||||
}
|
||||
return rooms;
|
||||
|
Reference in New Issue
Block a user