diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index e3cbee1..08b3124 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -84,7 +84,7 @@ class ApiClient { print("body:$bodyJson"); } var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes, isFormData: isFormData); - try { + // try { if (!kReleaseMode) { logger.i("res: " + response.body); } @@ -94,19 +94,19 @@ class ApiClient { AppState().setIsAuthenticated = jsonData["IsAuthenticated"]; } if (jsonData["ErrorMessage"] == null) { - return factoryConstructor(jsonData); + return factoryConstructor(jsonData["Data"]); } else { APIError? apiError; apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0, jsonData['ErrorStatusCode']); throw APIException(APIException.BAD_REQUEST, error: apiError); } - } catch (ex) { - if (ex is APIException) { - rethrow; - } else { - throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); - } - } + // } catch (ex) { + // if (ex is APIException) { + // rethrow; + // } else { + // throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); + // } + // } } Future postJsonForResponse(String url, T jsonObject, diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index 6412abe..406a240 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -52,7 +52,7 @@ class LoginApiClient { } Future checkMobileAppVersion() async { - String url = "${ApiConsts.utilitiesRest}CheckMobileAppVersion"; // todo @zahoor, not found in swagger + String url = "${ApiConsts.authRest}CheckMobileAppVersion"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) => CheckMobileAppVersionModel.fromJson(json), url, postParams); @@ -65,6 +65,7 @@ class LoginApiClient { return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); AppState().postParamsObject?.setLogInTokenID = responseData.logInTokenID; + print("setLogInTokenID:${AppState().postParamsObject?.logInTokenID}"); return responseData.memberLoginList; }, url, postParams); } @@ -73,12 +74,19 @@ class LoginApiClient { String url = "${ApiConsts.authRest}Mohemm_SendActivationCodebyOTPNotificationType"; Map postParams = {"IsMobileFingerPrint": isMobileFingerPrint, "MobileNumber": mobileNumber, "OTP_SendType": optSendType, "P_USER_NAME": pUserName}; postParams.addAll(AppState().postParamsJson); - return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json).basicMemberInformation, url, postParams); + postParams["LogInTokenID"]=AppState().postParamsObject?.logInTokenID; + print(postParams); + return await ApiClient().postJsonForObject((json) { + AppState().postParamsObject?.setLogInTokenID = json["LogInTokenID"]; + + return BasicMemberInformationModel.fromJson(json); + // GenericResponseModel.fromJson(json).basicMemberInformation; + }, url, postParams); } Future checkActivationCode(bool isDeviceNFC, String? mobileNumber, String activationCode, String? pUserName) async { String url = "${ApiConsts.authRest}CheckActivationCode"; - Map postParams = {"IsDeviceNFC": isDeviceNFC, "MobileNumber": mobileNumber, "activationCode": activationCode, "P_USER_NAME": pUserName}; + Map postParams = {"IsDeviceNFC": isDeviceNFC, "MobileNumber": mobileNumber, "ActivationCode": activationCode, "P_USER_NAME": pUserName}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index e87c3e0..857ef3d 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -659,6 +659,7 @@ class GenericResponseModel { this.isSMSSent}); GenericResponseModel.fromJson(Map json) { + print("json:$json"); date = json['Date']; languageID = json['LanguageID']; serviceName = json['ServiceName'];