Revert "formatted all files."

This reverts commit 04250ebc98.
This commit is contained in:
Faris Armoush
2025-06-12 16:04:49 +03:00
parent 218f43bacb
commit c642ba2644
473 changed files with 4335 additions and 5417 deletions

View File

@ -12,8 +12,7 @@ class AccessMangApi {
void _validateEndpoints() {
if (!ApiEndpoints.getDevices.contains('{projectId}')) {
throw Exception(
"Endpoint 'getDevices' must contain '{projectId}' placeholder.");
throw Exception("Endpoint 'getDevices' must contain '{projectId}' placeholder.");
}
}
@ -23,8 +22,8 @@ class AccessMangApi {
path: ApiEndpoints.visitorPassword,
showServerMessage: true,
expectedResponseModel: (json) {
final List<dynamic> jsonData = json['data'] ?? [];
final passwordList = jsonData.map((jsonItem) {
List<dynamic> jsonData = json['data'] ?? [];
List<PasswordModel> passwordList = jsonData.map((jsonItem) {
return PasswordModel.fromJson(jsonItem);
}).toList();
return passwordList;
@ -47,8 +46,8 @@ class AccessMangApi {
},
showServerMessage: true,
expectedResponseModel: (json) {
final List<dynamic> jsonData = json['data'] ?? [];
final deviceList = jsonData.map((jsonItem) {
List<dynamic> jsonData = json['data'] ?? [];
List<DeviceModel> deviceList = jsonData.map((jsonItem) {
return DeviceModel.fromJson(jsonItem);
}).toList();
return deviceList;
@ -70,13 +69,13 @@ class AccessMangApi {
final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword,
body: jsonEncode({
'email': email,
'passwordName': passwordName,
'password': password,
'devicesUuid': devicesUuid,
'effectiveTime': effectiveTime,
'invalidTime': invalidTime,
'operationType': 'ONLINE_ONE_TIME',
"email": email,
"passwordName": passwordName,
"password": password,
"devicesUuid": devicesUuid,
"effectiveTime": effectiveTime,
"invalidTime": invalidTime,
"operationType": "ONLINE_ONE_TIME",
}),
showServerMessage: true,
expectedResponseModel: (json) {
@ -94,18 +93,17 @@ class AccessMangApi {
String? passwordName,
List<Schedule>? scheduleList,
List<String>? devicesUuid}) async {
final body = <String, dynamic>{
'email': email,
'devicesUuid': devicesUuid,
'passwordName': passwordName,
'password': password,
'effectiveTime': effectiveTime,
'invalidTime': invalidTime,
'operationType': 'ONLINE_MULTIPLE_TIME',
Map<String, dynamic> body = {
"email": email,
"devicesUuid": devicesUuid,
"passwordName": passwordName,
"password": password,
"effectiveTime": effectiveTime,
"invalidTime": invalidTime,
"operationType": "ONLINE_MULTIPLE_TIME",
};
if (scheduleList != null) {
body['scheduleList'] =
scheduleList.map((schedule) => schedule.toJson()).toList();
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
}
final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword,
@ -125,10 +123,10 @@ class AccessMangApi {
final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword,
body: jsonEncode({
'operationType': 'OFFLINE_ONE_TIME',
'email': email,
'passwordName': passwordName,
'devicesUuid': devicesUuid
"operationType": "OFFLINE_ONE_TIME",
"email": email,
"passwordName": passwordName,
"devicesUuid": devicesUuid
}),
showServerMessage: true,
expectedResponseModel: (json) {
@ -147,12 +145,12 @@ class AccessMangApi {
final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword,
body: jsonEncode({
'email': email,
'devicesUuid': devicesUuid,
'passwordName': passwordName,
'effectiveTime': effectiveTime,
'invalidTime': invalidTime,
'operationType': 'OFFLINE_MULTIPLE_TIME',
"email": email,
"devicesUuid": devicesUuid,
"passwordName": passwordName,
"effectiveTime": effectiveTime,
"invalidTime": invalidTime,
"operationType": "OFFLINE_MULTIPLE_TIME",
}),
showServerMessage: true,
expectedResponseModel: (json) {

View File

@ -1,10 +1,10 @@
import 'dart:async';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_web/pages/auth/model/token.dart';
import 'package:syncrow_web/services/api/network_exception.dart';
import 'dart:async';
import 'package:syncrow_web/utils/constants/api_const.dart';
import 'package:syncrow_web/utils/snack_bar.dart';
@ -18,8 +18,7 @@ class HTTPInterceptor extends InterceptorsWrapper {
];
@override
Future<void> onResponse(
Response response, ResponseInterceptorHandler handler) async {
void onResponse(Response response, ResponseInterceptorHandler handler) async {
if (await validateResponse(response)) {
super.onResponse(response, handler);
} else {
@ -29,27 +28,26 @@ class HTTPInterceptor extends InterceptorsWrapper {
}
@override
Future<void> onRequest(
void onRequest(
RequestOptions options, RequestInterceptorHandler handler) async {
const storage = FlutterSecureStorage();
final token = await storage.read(key: Token.loginAccessTokenKey);
var storage = const FlutterSecureStorage();
var token = await storage.read(key: Token.loginAccessTokenKey);
if (checkHeaderExclusionListOfAddedParameters(options.path)) {
options.headers
.putIfAbsent(HttpHeaders.authorizationHeader, () => 'Bearer $token');
.putIfAbsent(HttpHeaders.authorizationHeader, () => "Bearer $token");
}
// options.headers['Authorization'] = 'Bearer ${'${token!}123'}';
super.onRequest(options, handler);
}
@override
Future<void> onError(
DioException err, ErrorInterceptorHandler handler) async {
final failure = ServerFailure.fromDioError(err);
void onError(DioException err, ErrorInterceptorHandler handler) async {
ServerFailure failure = ServerFailure.fromDioError(err);
if (failure.toString().isNotEmpty) {
CustomSnackBar.displaySnackBar(failure.toString());
}
const storage = FlutterSecureStorage();
final token = await storage.read(key: Token.loginAccessTokenKey);
var storage = const FlutterSecureStorage();
var token = await storage.read(key: Token.loginAccessTokenKey);
if (err.response?.statusCode == 401 && token != null) {
// await AuthCubit.get(NavigationService.navigatorKey.currentContext!).logout();
}
@ -74,10 +72,10 @@ class HTTPInterceptor extends InterceptorsWrapper {
}
}
bool checkHeaderExclusionListOfAddedParameters(String path) {
var shouldAddHeader = true;
checkHeaderExclusionListOfAddedParameters(String path) {
bool shouldAddHeader = true;
for (final urlConstant in headerExclusionListOfAddedParameters) {
for (var urlConstant in headerExclusionListOfAddedParameters) {
if (path.contains(urlConstant)) {
shouldAddHeader = false;
}

View File

@ -8,10 +8,10 @@ class HTTPService {
// final navigatorKey = GlobalKey<NavigatorState>();
String certificateString = '';
String certificateString = "";
static Dio setupDioClient() {
final client = Dio(
Dio client = Dio(
BaseOptions(
baseUrl: ApiEndpoints.baseUrl,
receiveDataWhenStatusError: true,

View File

@ -17,34 +17,34 @@ class ServerFailure extends Failure {
factory ServerFailure.fromDioError(DioException dioError) {
switch (dioError.type) {
case DioExceptionType.connectionTimeout:
return ServerFailure('Connection timeout with the Server.');
return ServerFailure("Connection timeout with the Server.");
case DioExceptionType.sendTimeout:
return ServerFailure('Send timeout with the Server.');
return ServerFailure("Send timeout with the Server.");
case DioExceptionType.receiveTimeout:
return ServerFailure('Receive timeout with the Server.');
return ServerFailure("Receive timeout with the Server.");
case DioExceptionType.badCertificate:
return ServerFailure('Bad certificate!');
return ServerFailure("Bad certificate!");
case DioExceptionType.badResponse:
{
// var document = parser.parse(dioError.response!.data.toString());
// var message = document.body!.text;
return ServerFailure.fromResponse(dioError.response!.statusCode,
dioError.response?.data['message'] ?? 'Error');
return ServerFailure.fromResponse(dioError.response!.statusCode!,
dioError.response?.data['message'] ?? "Error");
}
case DioExceptionType.cancel:
return ServerFailure('The request to ApiServer was canceled');
return ServerFailure("The request to ApiServer was canceled");
case DioExceptionType.connectionError:
return ServerFailure('No Internet Connection');
return ServerFailure("No Internet Connection");
case DioExceptionType.unknown:
return ServerFailure('Unexpected Error, Please try again!');
return ServerFailure("Unexpected Error, Please try again!");
default:
return ServerFailure('Unexpected Error, Please try again!');
return ServerFailure("Unexpected Error, Please try again!");
}
}
@ -54,9 +54,9 @@ class ServerFailure extends Failure {
case 403:
return ServerFailure(responseMessage);
case 400:
final errors = <String>[];
List<String> errors = [];
if (responseMessage is List) {
for (final error in responseMessage) {
for (var error in responseMessage) {
errors.add(error);
}
} else {
@ -64,11 +64,11 @@ class ServerFailure extends Failure {
}
return ServerFailure(errors.join('\n'));
case 404:
return ServerFailure('');
return ServerFailure("");
case 500:
return ServerFailure(responseMessage);
default:
return ServerFailure('Opps there was an Error, Please try again!');
return ServerFailure("Opps there was an Error, Please try again!");
}
}
}

View File

@ -31,7 +31,7 @@ class AuthenticationAPI {
try {
final response = await HTTPService().post(
path: ApiEndpoints.forgetPassword,
body: {'email': email, 'password': password, 'otpCode': otpCode},
body: {"email": email, "password": password, "otpCode": otpCode},
showServerMessage: true,
expectedResponseModel: (json) {});
return response;
@ -45,7 +45,7 @@ class AuthenticationAPI {
static Future<int?> sendOtp({required String email}) async {
final response = await HTTPService().post(
path: ApiEndpoints.sendOtp,
body: {'email': email, 'type': 'PASSWORD'},
body: {"email": email, "type": "PASSWORD"},
showServerMessage: true,
expectedResponseModel: (json) {
return json['data']['cooldown'];
@ -58,7 +58,7 @@ class AuthenticationAPI {
try {
final response = await HTTPService().post(
path: ApiEndpoints.verifyOtp,
body: {'email': email, 'type': 'PASSWORD', 'otpCode': otpCode},
body: {"email": email, "type": "PASSWORD", "otpCode": otpCode},
showServerMessage: true,
expectedResponseModel: (json) {
if (json['message'] == 'Otp Verified Successfully') {

View File

@ -11,8 +11,7 @@ abstract interface class BatchControlDevicesService {
});
}
final class RemoteBatchControlDevicesService
implements BatchControlDevicesService {
final class RemoteBatchControlDevicesService implements BatchControlDevicesService {
@override
Future<bool> batchControlDevices({
required List<String> uuids,

View File

@ -23,8 +23,8 @@ class DevicesManagementApi {
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
showServerMessage: true,
expectedResponseModel: (json) {
final List<dynamic> jsonData = json['data'];
final devicesList = jsonData.map((jsonItem) {
List<dynamic> jsonData = json['data'];
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
return AllDevicesModel.fromJson(jsonItem);
}).toList();
return devicesList;
@ -123,11 +123,11 @@ class DevicesManagementApi {
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
showServerMessage: false,
expectedResponseModel: (json) {
final devices = <DeviceModel>[];
List<DeviceModel> devices = [];
if (json == null || json.isEmpty || json == []) {
return devices;
}
for (final device in json['data']['devices']) {
for (var device in json['data']['devices']) {
devices.add(DeviceModel.fromJson(device));
}
return devices;
@ -203,7 +203,7 @@ class DevicesManagementApi {
}
}
Future getPowerStatus(List<String> uuids) async {
getPowerStatus(List<String> uuids) async {
try {
final queryParameters = {
'devicesUuid': uuids.join(','),
@ -254,8 +254,8 @@ class DevicesManagementApi {
.replaceAll('{category}', category),
showServerMessage: true,
expectedResponseModel: (json) {
final schedules = <ScheduleModel>[];
for (final schedule in json) {
List<ScheduleModel> schedules = [];
for (var schedule in json) {
schedules.add(ScheduleModel.fromMap(schedule));
}
return schedules;
@ -350,7 +350,7 @@ class DevicesManagementApi {
try {
final response = await HTTPService().put(
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
body: {'deviceName': deviceName},
body: {"deviceName": deviceName},
expectedResponseModel: (json) {
return json['data'];
},
@ -378,7 +378,7 @@ class DevicesManagementApi {
path: ApiEndpoints.resetDevice.replaceAll('{deviceUuid}', devicesUuid!),
showServerMessage: false,
body: {
'devicesUuid': [devicesUuid]
"devicesUuid": [devicesUuid]
},
expectedResponseModel: (json) {
return json;

View File

@ -5,7 +5,7 @@ import 'package:syncrow_web/services/api/http_service.dart';
final GetIt serviceLocator = GetIt.instance;
//setupLocator() // to search for dependency injection in flutter
void initialSetup() {
initialSetup() {
serviceLocator.registerSingleton<HTTPInterceptor>(HTTPInterceptor());
//Base classes
serviceLocator.registerSingleton<Dio>(HTTPService.setupDioClient());

View File

@ -9,9 +9,9 @@ class ProductApi {
final response = await HTTPService().get(
path: ApiEndpoints.listProducts,
expectedResponseModel: (json) {
final List<dynamic> jsonData = json['data'];
List<dynamic> jsonData = json['data'];
final productList = jsonData.map((jsonItem) {
List<ProductModel> productList = jsonData.map((jsonItem) {
return ProductModel.fromMap(jsonItem);
}).toList();
return productList;

View File

@ -29,7 +29,7 @@ class SceneApi {
debugPrint('create scene response: $response');
return response;
} on DioException catch (e) {
final String errorMessage =
String errorMessage =
e.response?.data['error']['message'][0] ?? 'something went wrong';
throw APIException(errorMessage);
}
@ -52,7 +52,7 @@ class SceneApi {
debugPrint('create automation response: $response');
return response;
} on DioException catch (e) {
final String errorMessage =
String errorMessage =
e.response?.data['error']['message'][0] ?? 'something went wrong';
throw APIException(errorMessage);
}
@ -63,7 +63,7 @@ class SceneApi {
path: ApiEndpoints.getIconScene,
showServerMessage: false,
expectedResponseModel: (json) {
final iconsList = <IconModel>[];
List<IconModel> iconsList = [];
json.forEach((element) {
iconsList.add(IconModel.fromJson(element));
});
@ -89,8 +89,8 @@ class SceneApi {
expectedResponseModel: (json) {
final scenesJson = json['data'] as List;
final scenes = <ScenesModel>[];
for (final scene in scenesJson) {
List<ScenesModel> scenes = [];
for (var scene in scenesJson) {
scenes.add(ScenesModel.fromJson(scene, isAutomation: false));
}
return scenes;
@ -114,8 +114,8 @@ class SceneApi {
.replaceAll('{projectId}', projectId),
showServerMessage: false,
expectedResponseModel: (json) {
final scenes = <ScenesModel>[];
for (final scene in json) {
List<ScenesModel> scenes = [];
for (var scene in json) {
scenes.add(ScenesModel.fromJson(scene, isAutomation: true));
}
return scenes;
@ -158,8 +158,7 @@ class SceneApi {
}
//update Scene
static Future updateScene(
CreateSceneModel createSceneModel, String sceneId) async {
static updateScene(CreateSceneModel createSceneModel, String sceneId) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.updateScene.replaceAll('{sceneId}', sceneId),
@ -171,14 +170,14 @@ class SceneApi {
);
return response;
} on DioException catch (e) {
final String errorMessage =
String errorMessage =
e.response?.data['error']['message'][0] ?? 'something went wrong';
throw APIException(errorMessage);
}
}
//update automation
static Future updateAutomation(CreateAutomationModel createAutomationModel,
static updateAutomation(CreateAutomationModel createAutomationModel,
String automationId, String projectId) async {
try {
final response = await _httpService.put(
@ -193,7 +192,7 @@ class SceneApi {
);
return response;
} on DioException catch (e) {
final String errorMessage =
String errorMessage =
e.response?.data['error']['message'][0] ?? 'something went wrong';
throw APIException(errorMessage);
}
@ -227,7 +226,7 @@ class SceneApi {
);
return response;
} on DioException catch (e) {
final String errorMessage =
String errorMessage =
e.response?.data['error']['message'][0] ?? 'something went wrong';
throw APIException(errorMessage);
}
@ -248,7 +247,7 @@ class SceneApi {
);
return response;
} on DioException catch (e) {
final String errorMessage =
String errorMessage =
e.response?.data['error']['message'][0] ?? 'something went wrong';
throw APIException(errorMessage);
}
@ -296,8 +295,8 @@ class SceneApi {
.replaceAll('{projectId}', projectId),
showServerMessage: false,
expectedResponseModel: (json) {
final scenes = <ScenesModel>[];
for (final scene in json) {
List<ScenesModel> scenes = [];
for (var scene in json) {
scenes.add(ScenesModel.fromJson(scene));
}
return scenes;

View File

@ -5,19 +5,22 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_m
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/create_subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_body_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
import 'package:syncrow_web/services/api/http_service.dart';
import 'package:syncrow_web/utils/constants/api_const.dart';
import '../pages/spaces_management/all_spaces/model/subspace_model.dart';
class CommunitySpaceManagementApi {
// Community Management APIs
Future<List<CommunityModel>> fetchCommunities(String projectId,
{int page = 1}) async {
try {
final allCommunities = <CommunityModel>[];
var hasNext = true;
List<CommunityModel> allCommunities = [];
bool hasNext = true;
while (hasNext) {
await HTTPService().get(
@ -28,10 +31,10 @@ class CommunitySpaceManagementApi {
},
expectedResponseModel: (json) {
try {
final List<dynamic> jsonData = json['data'] ?? [];
List<dynamic> jsonData = json['data'] ?? [];
hasNext = json['hasNext'] ?? false;
final int currentPage = json['page'] ?? 1;
final communityList = jsonData.map((jsonItem) {
int currentPage = json['page'] ?? 1;
List<CommunityModel> communityList = jsonData.map((jsonItem) {
return CommunityModel.fromJson(jsonItem);
}).toList();
allCommunities.addAll(communityList);
@ -53,10 +56,10 @@ class CommunitySpaceManagementApi {
Future<PaginationModel> fetchCommunitiesAndSpaces(
{required String projectId, int page = 1, String search = ''}) async {
var paginationModel = const PaginationModel.emptyConstructor();
PaginationModel paginationModel = const PaginationModel.emptyConstructor();
try {
var hasNext = false;
bool hasNext = false;
await HTTPService().get(
path:
ApiEndpoints.getCommunityList.replaceAll('{projectId}', projectId),
@ -68,10 +71,10 @@ class CommunitySpaceManagementApi {
},
expectedResponseModel: (json) {
try {
final List<dynamic> jsonData = json['data'] ?? [];
List<dynamic> jsonData = json['data'] ?? [];
hasNext = json['hasNext'] ?? false;
final int currentPage = json['page'] ?? 1;
final communityList = jsonData.map((jsonItem) {
int currentPage = json['page'] ?? 1;
List<CommunityModel> communityList = jsonData.map((jsonItem) {
return CommunityModel.fromJson(jsonItem);
}).toList();
@ -376,12 +379,12 @@ class CommunitySpaceManagementApi {
final response = await HTTPService().get(
path: path,
queryParameters: {'page': 1, 'pageSize': 10},
queryParameters: {"page": 1, "pageSize": 10},
showServerMessage: false,
expectedResponseModel: (json) {
final rooms = <SubSpaceModel>[];
List<SubSpaceModel> rooms = [];
if (json['data'] != null) {
for (final subspace in json['data']) {
for (var subspace in json['data']) {
rooms.add(SubSpaceModel.fromJson(subspace));
}
}
@ -390,7 +393,7 @@ class CommunitySpaceManagementApi {
);
return response;
} catch (error) {
} catch (error, stackTrace) {
return [];
}
}

View File

@ -79,7 +79,7 @@ class SpaceModelManagementApi {
.replaceAll('{projectId}', projectId)
.replaceAll('{spaceModelUuid}', spaceModelUuid),
showServerMessage: true,
body: {'spaceUuids': spaceUuids, 'overwrite': isOverWrite},
body: {"spaceUuids": spaceUuids, "overwrite": isOverWrite},
expectedResponseModel: (json) {
return json;
},
@ -92,7 +92,7 @@ class SpaceModelManagementApi {
path: ApiEndpoints.validateSpaceModel
.replaceAll('{projectId}', projectId),
showServerMessage: true,
body: {'spacesUuids': spaceUuids},
body: {"spacesUuids": spaceUuids},
expectedResponseModel: (json) {
return json;
});
@ -116,7 +116,7 @@ class SpaceModelManagementApi {
final response = await HTTPService().get(
path: ApiEndpoints.listTags.replaceAll('{projectId}', projectId),
expectedResponseModel: (json) {
final List<dynamic> jsonData = json['data'];
List<dynamic> jsonData = json['data'];
return jsonData.map((jsonItem) {
return Tag.fromJson(jsonItem);
}).toList();

View File

@ -23,18 +23,18 @@ class UserPermissionApi {
},
);
return response;
} catch (e) {
} catch (e, stackTrace) {
debugPrint('Error in fetchUsers: $e');
rethrow;
}
}
Future<List<RoleTypeModel>> fetchRoles() async {
fetchRoles() async {
final response = await _httpService.get(
path: ApiEndpoints.roleTypes,
showServerMessage: true,
expectedResponseModel: (json) {
final fetchedRoles = (json['data'] as List)
final List<RoleTypeModel> fetchedRoles = (json['data'] as List)
.map((item) => RoleTypeModel.fromJson(item))
.toList();
return fetchedRoles;
@ -45,7 +45,7 @@ class UserPermissionApi {
Future<List<PermissionOption>> fetchPermission(roleUuid) async {
final response = await _httpService.get(
path: ApiEndpoints.permission.replaceAll('roleUuid', roleUuid),
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
showServerMessage: true,
expectedResponseModel: (json) {
return (json as List)
@ -68,14 +68,14 @@ class UserPermissionApi {
}) async {
try {
final body = <String, dynamic>{
'firstName': firstName,
'lastName': lastName,
'email': email,
'jobTitle': jobTitle != '' ? jobTitle : null,
'phoneNumber': phoneNumber != '' ? phoneNumber : null,
'roleUuid': roleUuid,
'projectUuid': projectUuid,
'spaceUuids': spaceUuids,
"firstName": firstName,
"lastName": lastName,
"email": email,
"jobTitle": jobTitle != '' ? jobTitle : null,
"phoneNumber": phoneNumber != '' ? phoneNumber : null,
"roleUuid": roleUuid,
"projectUuid": projectUuid,
"spaceUuids": spaceUuids,
};
final response = await _httpService.post(
path: ApiEndpoints.inviteUser,
@ -83,7 +83,7 @@ class UserPermissionApi {
body: jsonEncode(body),
expectedResponseModel: (json) {
if (json['statusCode'] != 400) {
return json['success'];
return json["success"];
} else {
return false;
}
@ -91,7 +91,7 @@ class UserPermissionApi {
);
return response ?? [];
} on DioException {
} on DioException catch (e) {
return false;
} catch (e) {
return false;
@ -103,10 +103,10 @@ class UserPermissionApi {
final response = await _httpService.post(
path: ApiEndpoints.checkEmail,
showServerMessage: true,
body: {'email': email},
body: {"email": email},
expectedResponseModel: (json) {
if (json['statusCode'] != 400) {
final message = json['message'];
var message = json["message"];
if (message is String) {
return message;
} else {
@ -128,11 +128,11 @@ class UserPermissionApi {
Future<EditUserModel?> fetchUserById(userUuid, String projectId) async {
final response = await _httpService.get(
path: ApiEndpoints.getUserById
.replaceAll('{userUuid}', userUuid)
.replaceAll('{projectId}', projectId),
.replaceAll("{userUuid}", userUuid)
.replaceAll("{projectId}", projectId),
showServerMessage: true,
expectedResponseModel: (json) {
final res = EditUserModel.fromJson(json['data']);
EditUserModel res = EditUserModel.fromJson(json['data']);
return res;
},
);
@ -151,27 +151,27 @@ class UserPermissionApi {
}) async {
try {
final body = <String, dynamic>{
'firstName': firstName,
'lastName': lastName,
'jobTitle': jobTitle != '' ? jobTitle : ' ',
'phoneNumber': phoneNumber != '' ? phoneNumber : ' ',
'roleUuid': roleUuid,
'projectUuid': projectUuid,
'spaceUuids': spaceUuids,
"firstName": firstName,
"lastName": lastName,
"jobTitle": jobTitle != '' ? jobTitle : " ",
"phoneNumber": phoneNumber != '' ? phoneNumber : " ",
"roleUuid": roleUuid,
"projectUuid": projectUuid,
"spaceUuids": spaceUuids,
};
final response = await _httpService.put(
path: ApiEndpoints.editUser.replaceAll('{inviteUserUuid}', userId!),
body: jsonEncode(body),
expectedResponseModel: (json) {
if (json['statusCode'] != 400) {
return json['success'];
return json["success"];
} else {
return false;
}
},
);
return response;
} on DioException {
} on DioException catch (e) {
return false;
} catch (e) {
return false;
@ -181,7 +181,7 @@ class UserPermissionApi {
Future<bool> deleteUserById(userUuid) async {
try {
final response = await _httpService.delete(
path: ApiEndpoints.deleteUser.replaceAll('{inviteUserUuid}', userUuid),
path: ApiEndpoints.deleteUser.replaceAll("{inviteUserUuid}", userUuid),
showServerMessage: true,
expectedResponseModel: (json) {
return json['success'];
@ -193,17 +193,16 @@ class UserPermissionApi {
}
}
Future<bool> changeUserStatusById(
userUuid, status, String projectUuid) async {
Future<bool> changeUserStatusById(userUuid, status, String projectUuid) async {
try {
final bodya = <String, dynamic>{
'disable': status,
'projectUuid': projectUuid
Map<String, dynamic> bodya = {
"disable": status,
"projectUuid": projectUuid
};
final response = await _httpService.put(
path: ApiEndpoints.changeUserStatus
.replaceAll('{invitedUserUuid}', userUuid),
.replaceAll("{invitedUserUuid}", userUuid),
body: bodya,
expectedResponseModel: (json) {
return json['success'];