|
|
|
|
@ -13,6 +13,7 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/dependent/get_mobile_login_info_dependent_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/member_login_list_model.dart';
|
|
|
|
|
import 'package:sms_otp_auto_verify/sms_otp_auto_verify.dart';
|
|
|
|
|
|
|
|
|
|
class LoginApiClient {
|
|
|
|
|
static final LoginApiClient _instance = LoginApiClient._internal();
|
|
|
|
|
@ -21,6 +22,25 @@ class LoginApiClient {
|
|
|
|
|
|
|
|
|
|
factory LoginApiClient() => _instance;
|
|
|
|
|
|
|
|
|
|
static String? _cachedSignature;
|
|
|
|
|
|
|
|
|
|
static Future<String?> getSignature() async {
|
|
|
|
|
if (!Platform.isAndroid) return null;
|
|
|
|
|
if (_cachedSignature != null && _cachedSignature!.isNotEmpty) {
|
|
|
|
|
return _cachedSignature;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
String? sig = await SmsVerification.getAppSignature();
|
|
|
|
|
if (sig != null && sig.isNotEmpty) {
|
|
|
|
|
_cachedSignature = sig;
|
|
|
|
|
}
|
|
|
|
|
return sig;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
debugPrint("Error getting app signature: $e");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<GetMobileLoginInfoListModel?> getMobileLoginInfoNEW(String deviceToken, String deviceType, {int? memberType}) async {
|
|
|
|
|
String url = "${ApiConsts.erpRest}Mohemm_GetMobileLoginInfo_NEW";
|
|
|
|
|
Map<String, dynamic> postParams = {};
|
|
|
|
|
@ -186,8 +206,15 @@ class LoginApiClient {
|
|
|
|
|
}, url, postParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<BasicMemberInformationModel?> mohemmSendActivationCodeByOTPNotificationType(int isMobileFingerPrint, String? mobileNumber, int optSendType, String? pUserName) async {
|
|
|
|
|
Future<BasicMemberInformationModel?> mohemmSendActivationCodeByOTPNotificationType(
|
|
|
|
|
int isMobileFingerPrint,
|
|
|
|
|
String? mobileNumber,
|
|
|
|
|
int optSendType,
|
|
|
|
|
String? pUserName, {
|
|
|
|
|
String? smsSignature,
|
|
|
|
|
}) async {
|
|
|
|
|
String url = "${ApiConsts.erpRest}Mohemm_SendActivationCodebyOTPNotificationType";
|
|
|
|
|
String? sig = smsSignature ?? await getSignature();
|
|
|
|
|
Map<String, dynamic> postParams = {
|
|
|
|
|
"IsMobileFingerPrint": isMobileFingerPrint,
|
|
|
|
|
"MobileNumber": mobileNumber,
|
|
|
|
|
@ -197,6 +224,8 @@ class LoginApiClient {
|
|
|
|
|
"NotificationCenterAppSeviceGUID": ApiConsts.notificationCenterLoginServiceGUID,
|
|
|
|
|
};
|
|
|
|
|
postParams.addAll(AppState().postParamsJson);
|
|
|
|
|
postParams["smsSignature"] = sig ?? "";
|
|
|
|
|
postParams["SMSSignature"] = sig ?? "";
|
|
|
|
|
return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json).basicMemberInformation, url, postParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -228,8 +257,9 @@ class LoginApiClient {
|
|
|
|
|
return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json).basicMemberInformation, url, postParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<GenericResponseModel?> sendPublicActivationCode(String? mobileNumber, String? pUsername) async {
|
|
|
|
|
Future<GenericResponseModel?> sendPublicActivationCode(String? mobileNumber, String? pUsername, {String? smsSignature}) async {
|
|
|
|
|
String url = "${ApiConsts.erpRest}SendPublicActivationCode";
|
|
|
|
|
String? sig = smsSignature ?? await getSignature();
|
|
|
|
|
Map<String, dynamic> postParams = {
|
|
|
|
|
"MobileNumber": mobileNumber,
|
|
|
|
|
"P_MOBILE_NUMBER": mobileNumber,
|
|
|
|
|
@ -238,6 +268,8 @@ class LoginApiClient {
|
|
|
|
|
"NotificationCenterAppSeviceGUID": ApiConsts.notificationCenterForgotPasswordServiceGUID,
|
|
|
|
|
};
|
|
|
|
|
postParams.addAll(AppState().postParamsJson);
|
|
|
|
|
postParams["smsSignature"] = sig ?? "";
|
|
|
|
|
postParams["SMSSignature"] = sig ?? "";
|
|
|
|
|
return await ApiClient().postJsonForObject((json) {
|
|
|
|
|
GenericResponseModel responseData = GenericResponseModel.fromJson(json);
|
|
|
|
|
AppState().postParamsObject?.setLogInTokenID = responseData.logInTokenID;
|
|
|
|
|
@ -361,8 +393,10 @@ class LoginApiClient {
|
|
|
|
|
required String mobileNumber,
|
|
|
|
|
required String logInTokenID,
|
|
|
|
|
BuildContext? context,
|
|
|
|
|
String? smsSignature,
|
|
|
|
|
}) async {
|
|
|
|
|
String url = "${ApiConsts.erpRest}Mohemm_SendOTP_Dependent";
|
|
|
|
|
String? sig = smsSignature ?? await getSignature();
|
|
|
|
|
Map<String, dynamic> postParams = {
|
|
|
|
|
"VersionID": 20,
|
|
|
|
|
"Channel": 31,
|
|
|
|
|
@ -374,6 +408,8 @@ class LoginApiClient {
|
|
|
|
|
"P_DEP_NATIONAL_ID": nationalId,
|
|
|
|
|
"P_USER_NAME": nationalId,
|
|
|
|
|
"LogInTokenID": logInTokenID,
|
|
|
|
|
"smsSignature": sig ?? "",
|
|
|
|
|
"SMSSignature": sig ?? "",
|
|
|
|
|
};
|
|
|
|
|
return await ApiClient().postJsonForObject((json) {
|
|
|
|
|
GenericResponseModel responseData = GenericResponseModel.fromJson(json);
|
|
|
|
|
|