diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index 19ec9fb..81bc0f8 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -463,8 +463,8 @@ class ApiClient { Future postJsonForObject(FactoryConstructor factoryConstructor, String url, T jsonObject, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0, bool isFormData = false, bool returnJsonData = true}) async { var _headers = {'Accept': 'application/json'}; - if (token != null && token.isNotEmpty) { - _headers.addAll({'Bearer': '$token'}); + if (token != null && token.isNotEmpty && AppState().isLogged) { + _headers['Authorization'] = 'Bearer $token'; } // logger.d(_headers); @@ -480,10 +480,10 @@ class ApiClient { } // Remove "logInTokenID" and "tokenID" from jsonObject if present - if (jsonObject is Map && AppState().isLogged) { - jsonObject.remove("logInTokenID"); - jsonObject.remove("tokenID"); - } + // if (jsonObject is Map && AppState().isLogged) { + // jsonObject.remove("logInTokenID"); + // jsonObject.remove("tokenID"); + // } var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes, isFormData: isFormData); @@ -571,7 +571,7 @@ class ApiClient { }) async { try { var _headers = {}; - if (token != null) { + if (token != null && AppState().isLogged) { _headers['Authorization'] = 'Bearer $token'; } diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index 0f0c589..0b0fd0c 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -61,9 +61,7 @@ class LoginApiClient { dynamic response = await ApiClient().postJsonForObject((json) => json, url, postParams, token: AppState().postParamsObject!.tokenID); ApiResponse res = ApiResponse.fromJson(response); dynamic ress = await ApiClassMapper().handleApiEndpoint(endpoint: "Mohemm_Insert_MobileDeviceInfo", jsonData: res); - if (ress == true) { - AppState().setLogged = true; - } + return ress; } diff --git a/lib/models/dashboard/get_accrual_balances_list_model.dart b/lib/models/dashboard/get_accrual_balances_list_model.dart index f41bb81..aba3e33 100644 --- a/lib/models/dashboard/get_accrual_balances_list_model.dart +++ b/lib/models/dashboard/get_accrual_balances_list_model.dart @@ -1,43 +1,3 @@ -// class GetAccrualBalancesList { -// GetAccrualBalancesList({ -// this.accrualNetEntitlement, -// this.accrualUsedEntitlement, -// this.accrualYearlyEntitlement, -// this.accuralPlanName, -// this.endDate, -// this.lastAccrualDate, -// this.startDate, -// }); -// -// double? accrualNetEntitlement; -// num? accrualUsedEntitlement; //Todo: Add function -// dynamic accrualYearlyEntitlement; -// String? accuralPlanName; -// String? endDate; -// String? lastAccrualDate; -// String? startDate; -// -// factory GetAccrualBalancesList.fromJson(Map json) => GetAccrualBalancesList( -// accrualNetEntitlement: json["ACCRUAL_NET_ENTITLEMENT"] == null ? null : json["ACCRUAL_NET_ENTITLEMENT"].toDouble(), -// accrualUsedEntitlement: json["ACCRUAL_USED_ENTITLEMENT"] == null ? null : json["ACCRUAL_USED_ENTITLEMENT"], -// accrualYearlyEntitlement: json["ACCRUAL_YEARLY_ENTITLEMENT"], -// accuralPlanName: json["ACCURAL_PLAN_NAME"] == null ? null : json["ACCURAL_PLAN_NAME"], -// endDate: json["END_DATE"] == null ? null : json["END_DATE"], -// lastAccrualDate: json["LAST_ACCRUAL_DATE"] == null ? null : json["LAST_ACCRUAL_DATE"], -// startDate: json["START_DATE"] == null ? null : json["START_DATE"], -// ); -// -// Map toJson() => { -// "ACCRUAL_NET_ENTITLEMENT": accrualNetEntitlement == null ? null : accrualNetEntitlement, -// "ACCRUAL_USED_ENTITLEMENT": accrualUsedEntitlement == null ? null : accrualUsedEntitlement, -// "ACCRUAL_YEARLY_ENTITLEMENT": accrualYearlyEntitlement, -// "ACCURAL_PLAN_NAME": accuralPlanName == null ? null : accuralPlanName, -// "END_DATE": endDate == null ? null : endDate, -// "LAST_ACCRUAL_DATE": lastAccrualDate == null ? null : lastAccrualDate, -// "START_DATE": startDate == null ? null : startDate, -// }; -// } - import 'dart:convert'; class GetAccrualBalancesList { @@ -47,7 +7,7 @@ class GetAccrualBalancesList { DateTime? lasTAccrualDate; dynamic accruaLYearlyEntitlement; double? accruaLNetEntitlement; - int? accruaLUsedEntitlement; + double? accruaLUsedEntitlement; GetAccrualBalancesList({ this.accuraLPlanName, @@ -69,8 +29,8 @@ class GetAccrualBalancesList { enDDate: json["enD_DATE"] == null ? null : DateTime.parse(json["enD_DATE"]), lasTAccrualDate: json["lasT_ACCRUAL_DATE"] == null ? null : DateTime.parse(json["lasT_ACCRUAL_DATE"]), accruaLYearlyEntitlement: json["accruaL_YEARLY_ENTITLEMENT"], - accruaLNetEntitlement: json["accruaL_NET_ENTITLEMENT"]?.toDouble(), - accruaLUsedEntitlement: json["accruaL_USED_ENTITLEMENT"], + accruaLNetEntitlement: json["accruaL_NET_ENTITLEMENT"].toDouble(), + accruaLUsedEntitlement: json["accruaL_USED_ENTITLEMENT"]?.toDouble(), ); Map toJson() => { @@ -79,8 +39,7 @@ class GetAccrualBalancesList { "enD_DATE": enDDate?.toIso8601String(), "lasT_ACCRUAL_DATE": lasTAccrualDate?.toIso8601String(), "accruaL_YEARLY_ENTITLEMENT": accruaLYearlyEntitlement, - "accruaL_NET_ENTITLEMENT": accruaLNetEntitlement, + "accruaL_NET_ENTITLEMENT": accruaLNetEntitlement?.toDouble(), "accruaL_USED_ENTITLEMENT": accruaLUsedEntitlement, }; } -