callDealerAssetApi method
Future<void>
callDealerAssetApi(
- String filterStatus,
- String userId,
- String productCode,
- StockDealerContentModel? modelData,
- CheckStockContentModel? modelProduct,
- String? keyword,
- String? startRange,
- String? endRange,
- String? fromPurchase,
- String? toPurchase,
- String? fromExpiry,
- String? toExpiry,
- int pageNo, {
- int pageCount = 20,
- required bool isFromCheckin,
- required int categoryId,
- required String categoryName,
Implementation
Future<void> callDealerAssetApi(
String filterStatus,
String userId,
String productCode,
StockDealerContentModel? modelData,
CheckStockContentModel? modelProduct,
String? keyword,
String? startRange,
String? endRange,
String? fromPurchase,
String? toPurchase,
String? fromExpiry,
String? toExpiry,
int pageNo, {
int pageCount = 20,
required bool isFromCheckin,
required int categoryId,
required String categoryName,
//String? query,
}) async {
try {
Helper.hideKeyboard();
BuildContext context = Get.context!;
if (pageNo == 1) {
Helper.progressDialog(context, "Please wait..");
}
String requestTime = "";
String responseTime = "";
await ApiClient(
baseUrl: ApiConstant.armBaseUrl,
onFetchRequestTime: (time) {
requestTime = time;
},
onFetchResponseTime: (time) {
responseTime = time;
},
screenName: "checkStock",
)
.getAssetDetails(
filterRetailerNumber: userId,
filterStatusId: "4",
pageNo: pageNo,
assetStartRange: startRange,
assetEndRange: endRange,
filterPurchaseFromDate: fromPurchase,
filterPurchaseToDate: toPurchase,
filterExpiryFromDate: fromExpiry,
filterExpiryToDate: toExpiry,
perPageCount: pageCount,
filterProductCode: productCode,
xUserId: SecureStorageService.readSecureData(
SecureStorageService.xUserId,
),
sort: "serialnumberNumeric",
filterSerialNumberLike: keyword,
)
.then((response) {
Helper.logEvent(
"RESPONSE_EVENT",
success: true,
endPoint: Api.getAssetDetails,
responseDate: responseTime,
screenName: "checkStock",
requestDate: requestTime,
);
StockDealerAssetModel model = response;
if (model.status == true) {
if (model.data != null) {
if (pageNo == 1) {
dealerAssetList.value = model.data!.content ?? [];
dealerSearchedAssetList.value = dealerAssetList;
} else {
dealerAssetList.addAll(model.data!.content ?? []);
dealerSearchedAssetList.value = dealerAssetList;
}
}
totalList = model.data!.totalElements ?? 0;
isLoadingMore.value = false;
/* Get.to(
() => CheckStockAsset(
dealerModel: modelData,
model: modelProduct,
isFromCheckin: isFromCheckin,
),
);*/
// if (pageNo == 1) {
// Get.back();
// if (query == null) {
// CheckStockAssetBottomSheet().checkStockAsset(
// context,
// modelProduct,
// isFromCheckin,
// pageNo,
// );
// }
// }
if (pageNo == 1) {
Get.back();
//if (keyword == null) {
Get.to(
() => CheckStockAssetDetails(
modelProduct: modelProduct,
categoryId: categoryId,
categoryName: categoryName),
);
//}
}
} else {
if (model.errors != null) {
Helper.messageDialog(
Get.context!,
model.errors![0].errorCode ?? localization.translate("tryAgain"),
model.errors![0].errorDescription ??
localization.translate("somethingWentWrong"),
);
}
}
}).catchError((error) {
ConditionalLogs().customLog("$error");
if (pageNo == 1) {
Get.back();
}
MainController mainController = Get.put(MainController());
mainController.showErrorPopup();
});
} catch (e) {
if (pageNo == 1) {
Get.back();
}
}
}