callDealerDetailsApi method
Implementation
Future<void> callDealerDetailsApi(String dealerId) async {
BuildContext context = Get.context!;
Helper.progressDialog(context, "Please wait..");
try {
String requestTime = "";
String responseTime = "";
await ApiClient(
baseUrl: ApiConstant.baseUrl,
onFetchRequestTime: (time) {
requestTime = time;
},
onFetchResponseTime: (time) {
responseTime = time;
},
screenName: "collectStockHistoryDetails",
)
.getMoreInfo(
dealerId: dealerId,
xUserId: SecureStorageService.readSecureData(
SecureStorageService.xUserId,
) ??
"",
)
.then((response) async {
Helper.logEvent(
"RESPONSE_EVENT",
success: true,
endPoint: "${Api.getMoreInfo}/$dealerId",
responseDate: responseTime,
screenName: "collectStockHistoryDetails",
requestDate: requestTime,
);
DealerDetailsModel model = response;
if (model.profile != null) {
if (model.profile!.address != null) {
regionName = model.profile!.address!.locationName4 ?? "";
}
storage.write("REGION_NAME", regionName);
levelName = model.profile!.levelName ?? "";
storage.write("LEVEL_NAME", levelName);
storage.write("PARTNER_ID ", model.profile!.partnerId ?? "");
levelId = model.profile!.levelId ?? 0;
storage.write("LEVEL_ID", levelId);
// levelId = 5;
Get.back();
await callDistributerLevelApi(levelId);
} else {
Get.back();
}
}).catchError((error) {
ConditionalLogs().customLog("$error");
GenericResponse res = GenericResponse.fromJson(error?.response?.data);
Get.back();
Helper.messageDialog(
Get.context!,
res.responseCode ?? "Try Again!!",
res.responseMessage ?? "Unknown error",
);
});
} catch (err, stacktrace) {
ConditionalLogs().customLog("$stacktrace");
Get.back();
Get.snackbar("Try Again!!", err.toString());
}
}