Merge pull request #66 from SyncrowIOT/Implement_Change_Password_Flow

change_password
This commit is contained in:
mohammadnemer1
2025-01-16 18:02:33 +03:00
committed by GitHub
50 changed files with 3020 additions and 524 deletions
@@ -63,6 +63,8 @@ abstract class ApiEndpoints {
static const String unitUser = '/unit/user/';
static const String invitationCode =
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{unitUuid}/invitation-code';
static const String activationCode =
'/invite-user/activation';
//PUT
static const String renameUnit = '/unit/{unitUuid}';
-1
View File
@@ -41,7 +41,6 @@ class AuthenticationAPI {
body: body,
showServerMessage: false,
expectedResponseModel: (json) {
print(json['data']);
return json['data'];
});
return response;
+6 -6
View File
@@ -448,14 +448,14 @@ class DevicesAPI {
required String startTime,
required String endTime,
}) async {
final requestUrl = ApiEndpoints.reportLogs
.replaceAll('{deviceUuid}', deviceUuid)
.replaceAll('{code}', code)
.replaceAll('{startTime}', startTime)
.replaceAll('{endTime}', endTime);
final response = await _httpService.get(
path: ApiEndpoints.reportLogs
.replaceAll('{deviceUuid}', deviceUuid)
.replaceAll('{code}', code)
.replaceAll('{startTime}', startTime)
.replaceAll('{endTime}', endTime),
path: requestUrl,
expectedResponseModel: (json) {
log('json=====$json');
return DeviceReport.fromJson(json);
},
);
-1
View File
@@ -1,5 +1,4 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
+5 -11
View File
@@ -31,8 +31,10 @@ class ServerFailure extends Failure {
{
// var document = parser.parse(dioError.response!.data.toString());
// var message = document.body!.text;
return ServerFailure.fromResponse(dioError.response!.statusCode!,
dioError.response?.data['error']['message'] ?? "Something went wrong");
return ServerFailure.fromResponse(
dioError.response!.statusCode!,
dioError.response?.data['error']['message'] ??
"Something went wrong");
}
case DioExceptionType.cancel:
return ServerFailure("The request to ApiServer was canceled");
@@ -54,15 +56,7 @@ class ServerFailure extends Failure {
case 403:
return ServerFailure(responseMessage);
case 400:
List<String> errors = [];
if (responseMessage is List) {
for (var error in responseMessage) {
errors.add(error);
}
} else {
return ServerFailure(responseMessage);
}
return ServerFailure(errors.join('\n'));
return ServerFailure(responseMessage);
case 404:
return ServerFailure("");
case 500:
+32 -27
View File
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/menu/model/region_model.dart';
@@ -9,14 +10,15 @@ import 'package:syncrow_app/services/api/http_service.dart';
class ProfileApi {
static final HTTPService _httpService = HTTPService();
static Future<Map<String, dynamic>> saveName({String? firstName, String? lastName,}) async {
static Future<Map<String, dynamic>> saveName({
String? firstName,
String? lastName,
}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveName.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"firstName": firstName,
"lastName": lastName
},
path: ApiEndpoints.saveName
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {"firstName": firstName, "lastName": lastName},
expectedResponseModel: (json) {
return json;
},
@@ -27,10 +29,13 @@ class ProfileApi {
}
}
static Future saveRegion({String? regionUuid,}) async {
static Future saveRegion({
String? regionUuid,
}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveRegion.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
path: ApiEndpoints.saveRegion
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"regionUuid": regionUuid,
},
@@ -44,10 +49,13 @@ class ProfileApi {
}
}
static Future saveTimeZone({String? regionUuid,}) async {
static Future saveTimeZone({
String? regionUuid,
}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveTimeZone.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
path: ApiEndpoints.saveTimeZone
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"timezoneUuid": regionUuid,
},
@@ -64,10 +72,9 @@ class ProfileApi {
static Future<Map<String, dynamic>> saveImage(String image) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.sendPicture.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"profilePicture": 'data:image/png;base64,$image'
},
path: ApiEndpoints.sendPicture
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {"profilePicture": 'data:image/png;base64,$image'},
expectedResponseModel: (json) {
return json;
},
@@ -78,14 +85,13 @@ class ProfileApi {
}
}
Future fetchUserInfo(userId) async {
Future fetchUserInfo(userId) async {
final response = await _httpService.get(
path: ApiEndpoints.getUser.replaceAll('{userUuid}', userId!),
showServerMessage: true,
expectedResponseModel: (json) {
return UserModel.fromJson(json);
}
);
path: ApiEndpoints.getUser.replaceAll('{userUuid}', userId!),
showServerMessage: true,
expectedResponseModel: (json) {
return UserModel.fromJson(json);
});
return response;
}
@@ -94,9 +100,10 @@ class ProfileApi {
path: ApiEndpoints.getRegion,
showServerMessage: true,
expectedResponseModel: (json) {
return (json as List).map((zone) => RegionModel.fromJson(zone)).toList();
}
);
return (json as List)
.map((zone) => RegionModel.fromJson(zone))
.toList();
});
return response as List<RegionModel>;
}
@@ -106,9 +113,7 @@ class ProfileApi {
showServerMessage: true,
expectedResponseModel: (json) {
return (json as List).map((zone) => TimeZone.fromJson(zone)).toList();
}
);
});
return response as List<TimeZone>;
}
}
+18 -1
View File
@@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart';
@@ -66,7 +67,7 @@ class SpacesAPI {
static Future<String> generateInvitationCode(
String unitId, String communityId) async {
final response = await _httpService.get(
final response = await _httpService.post(
path: ApiEndpoints.invitationCode
.replaceAll('{unitUuid}', unitId)
.replaceAll('{communityUuid}', communityId)
@@ -95,4 +96,20 @@ class SpacesAPI {
);
return response;
}
static Future activationCodeSpace({
String? activationCode,
String? userUuid,
}) async {
Map body = {"activationCode": activationCode, "userUuid": userUuid};
final response = await _httpService.post(
path: ApiEndpoints.activationCode,
showServerMessage: true,
body: body,
expectedResponseModel: (json) {
return json;
},
);
return response;
}
}