mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 01:35:23 +00:00

- Add method to get token and validate in AuthCubit - Update AuthState with loading, success, and error states for token - Use BlocBuilder in SplashView for token validation and navigation This commit refactors the code in AuthCubit to include a method to get the token and validate it. It also updates the AuthState with loading, success, and error states for token handling. In SplashView, BlocBuilder is now used to handle token validation and navigation based on the token status.
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
|
import 'package:syncrow_app/services/api/http_service.dart';
|
|
|
|
class DevicesAPI {
|
|
static final HTTPService _httpService = HTTPService();
|
|
|
|
static Future<Map<String, dynamic>> controlDevice(
|
|
DeviceControlModel controlModel) async {
|
|
final response = await _httpService.post(
|
|
path: ApiEndpoints.control,
|
|
body: controlModel.toJson(),
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) {
|
|
return json;
|
|
},
|
|
);
|
|
return response;
|
|
}
|
|
|
|
static Future<List<DevicesCategoryModel>> fetchGroups(int spaceId) async {
|
|
Map<String, dynamic> params = {
|
|
"homeId": spaceId,
|
|
"pageSize": 100,
|
|
"pageNo": 1
|
|
};
|
|
final response = await _httpService.get(
|
|
path: ApiEndpoints.groups,
|
|
queryParameters: params,
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) =>
|
|
DevicesCategoryModel.fromJsonList(json['groups']),
|
|
);
|
|
return response;
|
|
}
|
|
}
|