mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
64 lines
1.8 KiB
Dart
64 lines
1.8 KiB
Dart
import 'package:syncrow_web/pages/roles_and_permission/model/role_type_model.dart';
|
|
import 'package:syncrow_web/pages/roles_and_permission/users_page/view/roles_and_permission.dart';
|
|
import 'package:syncrow_web/services/api/http_service.dart';
|
|
import 'package:syncrow_web/utils/constants/api_const.dart';
|
|
|
|
class UserPermissionApi {
|
|
static final HTTPService _httpService = HTTPService();
|
|
|
|
fetchRoles() async {
|
|
final response = await _httpService.get(
|
|
path: ApiEndpoints.roleTypes,
|
|
showServerMessage: true,
|
|
expectedResponseModel: (json) {
|
|
final List<RoleTypeModel> fetchedRoles = (json['data'] as List)
|
|
.map((item) => RoleTypeModel.fromJson(item))
|
|
.toList();
|
|
return fetchedRoles;
|
|
},
|
|
);
|
|
return response;
|
|
}
|
|
|
|
Future<List<PermissionOption>> fetchPermission(roleUuid) async {
|
|
final response = await _httpService.get(
|
|
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
|
|
showServerMessage: true,
|
|
expectedResponseModel: (json) {
|
|
return (json as List)
|
|
.map((data) => PermissionOption.fromJson(data))
|
|
.toList();
|
|
},
|
|
);
|
|
return response ?? [];
|
|
}
|
|
|
|
Future sendInviteUser({
|
|
String? firstName,
|
|
String? lastName,
|
|
String? email,
|
|
String? jobTitle,
|
|
String? phoneNumber,
|
|
String? roleUuid,
|
|
List<String>? spaceUuids,
|
|
}) async {
|
|
final response = await _httpService.post(
|
|
path: ApiEndpoints.permission,
|
|
showServerMessage: true,
|
|
body: {
|
|
"firstName": firstName,
|
|
"lastName": lastName,
|
|
"email": email,
|
|
"jobTitle": jobTitle,
|
|
"phoneNumber": phoneNumber,
|
|
"roleUuid": roleUuid,
|
|
"spaceUuids": spaceUuids
|
|
},
|
|
expectedResponseModel: (json) {
|
|
print(json);
|
|
},
|
|
);
|
|
return response ?? [];
|
|
}
|
|
}
|