mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 09:27:54 +00:00
141 lines
4.3 KiB
Dart
141 lines
4.3 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:syncrow_app/features/auth/model/token.dart';
|
|
import 'package:syncrow_app/features/auth/model/verify_code.dart';
|
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
|
import 'package:syncrow_app/services/api/http_service.dart';
|
|
|
|
class AuthenticationAPI {
|
|
static Future<Token> verifyPassCode(VerifyPassCode data) async {
|
|
final response = await HTTPService().post(
|
|
path: ApiEndpoints.verifyOtp,
|
|
body: data.toJson(),
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) {
|
|
Token token = Token.fromJson(json);
|
|
return token;
|
|
});
|
|
return response;
|
|
}
|
|
|
|
static Future<Token> loginWithEmail(
|
|
{required String email, required String password}) async {
|
|
final response = await HTTPService().post(
|
|
path: ApiEndpoints.login,
|
|
body: jsonEncode({
|
|
"email": email,
|
|
"password": password,
|
|
}),
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) {
|
|
Token token = Token.fromJson(json['data']);
|
|
return token;
|
|
});
|
|
debugPrint("response: $response");
|
|
return response;
|
|
}
|
|
|
|
// static Future<SuccessResponse> updateUserInfo(
|
|
// Map<String, dynamic> data) async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.updateUserInfo,
|
|
// body: data,
|
|
// expectedResponseModel: (json) {
|
|
// SuccessResponse token = SuccessResponse.fromJson(json);
|
|
// return token;
|
|
// });
|
|
// return response;
|
|
// }
|
|
//
|
|
// static Future<LoginWithPhoneResponse> loginWithPhone(
|
|
// {required LoginWithPhone data, String? recaptchaToken}) async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.loginWithChannel,
|
|
// body: data.toJson(),
|
|
// options: Options(headers: {
|
|
// 'captcha-token': recaptchaToken,
|
|
// 'captcha-site-key': Platform.isAndroid
|
|
// ? dotenv.env['RECAPTCH_ANDROID_SITE_KEY'] ?? ''
|
|
// : dotenv.env['RECAPTCH_IOS_SITE_KEY'] ?? ''
|
|
// }),
|
|
// expectedResponseModel: (json) {
|
|
// LoginWithPhoneResponse result = LoginWithPhoneResponse.fromJson(json);
|
|
// return result;
|
|
// });
|
|
// return response;
|
|
// }
|
|
//
|
|
// static Future<List<dynamic>> countryCodes() async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.getCountyCode,
|
|
// expectedResponseModel: (json) {
|
|
// List<dynamic> result = json.toList();
|
|
// return result;
|
|
// });
|
|
// return response;
|
|
// }
|
|
//
|
|
// static Future<bool> sendNotificationToken({
|
|
// required Map<String, String> data,
|
|
// }) async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.notificationToken,
|
|
// body: data,
|
|
// showServerMessage: false,
|
|
// expectedResponseModel: (json) {
|
|
// bool checked = false;
|
|
// if (json != null) {
|
|
// if (json['success']) {
|
|
// checked = true;
|
|
// }
|
|
// }
|
|
// return checked;
|
|
// });
|
|
// return response;
|
|
// }
|
|
//
|
|
// static Future<bool> logout() async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.logout,
|
|
// expectedResponseModel: (json) {
|
|
// bool checked = false;
|
|
// // print(json);
|
|
// if (json != null) {
|
|
// if (json['success']) {
|
|
// checked = true;
|
|
// }
|
|
// }
|
|
// return checked;
|
|
// });
|
|
// return response;
|
|
// }
|
|
//
|
|
// static Future<bool> deleteAccount() async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.deleteAccount,
|
|
// expectedResponseModel: (json) {
|
|
// bool checked = false;
|
|
// if (json != null) {
|
|
// if (json['success']) {
|
|
// checked = true;
|
|
// }
|
|
// }
|
|
// return checked;
|
|
// });
|
|
// return response;
|
|
// }
|
|
|
|
// static Future<Token> refreshToken(Map<String, dynamic> data) async {
|
|
// final response = await HTTPService().postRequest(
|
|
// path: APIConstants.refreshToken,
|
|
// showServerMessage: false,
|
|
// body: data,
|
|
// expectedResponseModel: (json) {
|
|
// Token token = Token.fromJson(json);
|
|
// return token;
|
|
// });
|
|
// return response;
|
|
// }
|
|
}
|