mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
51 lines
1.4 KiB
Dart
51 lines
1.4 KiB
Dart
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
|
import 'package:syncrow_web/services/api/http_service.dart';
|
|
import 'package:syncrow_web/utils/constants/api_const.dart';
|
|
|
|
class HomeApi {
|
|
Future<UserModel?> fetchUserInfo(String userId) async {
|
|
try {
|
|
final response = await HTTPService().get(
|
|
path: ApiEndpoints.getUser.replaceAll('{userUuid}', userId),
|
|
showServerMessage: true,
|
|
expectedResponseModel: (json) {
|
|
final user = UserModel.fromJson(json as Map<String, dynamic>);
|
|
return user;
|
|
},
|
|
);
|
|
return response;
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
Future fetchTerms() async {
|
|
final response = await HTTPService().get(
|
|
path: ApiEndpoints.terms,
|
|
showServerMessage: true,
|
|
expectedResponseModel: (json) {
|
|
return json['data'];
|
|
});
|
|
return response;
|
|
}
|
|
|
|
Future fetchPolicy() async {
|
|
final response = await HTTPService().get(
|
|
path: ApiEndpoints.policy,
|
|
showServerMessage: true,
|
|
expectedResponseModel: (json) {
|
|
return json['data'];
|
|
});
|
|
return response;
|
|
}
|
|
|
|
Future confirmUserAgreements(uuid) async {
|
|
final response = await HTTPService().patch(
|
|
path: ApiEndpoints.userAgreements.replaceAll('{userUuid}', uuid!),
|
|
expectedResponseModel: (json) {
|
|
return json['data'];
|
|
});
|
|
return response;
|
|
}
|
|
}
|