Files
syncrow-app/lib/services/api/authentication_api.dart
2025-07-08 16:21:37 +03:00

94 lines
2.8 KiB
Dart

import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
import 'package:syncrow_app/features/auth/model/signup_model.dart';
import 'package:syncrow_app/features/auth/model/token.dart';
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_service.dart';
class AuthenticationAPI {
static Future<Map<String, dynamic>> verifyPassCode(
{required Map<String, dynamic> body}) async {
final response = await HTTPService().post(
path: ApiEndpoints.verifyOtp,
body: body,
showServerMessage: false,
expectedResponseModel: (json) => json);
return response;
}
static Future<Token> loginWithEmail(
{required LoginWithEmailModel model}) async {
final response = await HTTPService().post(
path: ApiEndpoints.login,
body: model.toJson(),
showServerMessage: false,
expectedResponseModel: (json) => Token.fromJson(json['data']));
return response;
}
static Future<bool> signUp({
required SignUpModel model,
required String accessToken,
}) async {
final response = await HTTPService().post(
path: ApiEndpoints.signUp,
body: model.toJson(),
showServerMessage: false,
accessToken: accessToken,
expectedResponseModel: (json) => json['statusCode'] == 201);
return response;
}
static Future<Map<String, dynamic>> sendOtp(
{required Map<String, dynamic> body}) async {
final response = await HTTPService().post(
path: ApiEndpoints.sendOtp,
body: body,
showServerMessage: false,
expectedResponseModel: (json) {
return json['data'];
});
return response;
}
static Future<Map<String, dynamic>> forgetPassword({
required String otpCode,
required String email,
required String password,
}) async {
Map<String, dynamic> params = {
"email": email,
"password": password,
"otpCode": otpCode
};
final response = await HTTPService().post(
path: ApiEndpoints.forgetPassword,
body: params,
showServerMessage: false,
expectedResponseModel: (json) => json['data']);
return response;
}
static Future<Map<String, dynamic>> fetchClientToken({
required String clientId,
required String clientSecret,
}) async {
final response = await HTTPService().post(
path: ApiEndpoints.clientLogin,
body: {
'clientId': clientId,
'clientSecret': clientSecret,
},
showServerMessage: false,
expectedResponseModel: (json) => json['data'],
);
return response;
}
static Future<void> deleteAccount() async {
await HTTPService().delete(
path: ApiEndpoints.deleteProfile,
expectedResponseModel: (p0) {},
);
}
}