callproductDetailsApi method

Future<void> callproductDetailsApi(
  1. List<Partner> partner,
  2. ScanModel scanModel
)

Implementation

Future<void> callproductDetailsApi(
    List<Partner> partner, ScanModel scanModel) async {
  ConditionalLogs().customLog("$partner");
  BuildContext context = Get.context!;
  Helper.progressDialog(context, "Please wait..");
  partner.forEach((element) {
    partnerIds.add(element.partnerId!);
  });
  dio
      .get(
    'https://run.mocky.io/v3/12f04fd8-f7d0-4b34-b71e-9f21f91cf580',
    data: {
      'partnerIds': partnerIds,
    },
    options: Options(
      headers: {
        'Authorization': 'Bearer Authorization',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    ),
  )
      .then((response) {
    Helper.close();
    if (response.data != null) {
      ProductdataModel model = ProductdataModel();
      ConditionalLogs().customLog("${response.data}");
      Map<String, dynamic> productData = response.data;
      if (productData['status']) {
        DataproductModel dataproductModel =
            DataproductModel.fromJson(productData['data']);
        productDataList.value = dataproductModel.content!;
        productDataScannedList.value = productDataList;
        searchedScannedList.value = productDataList;
        Get.to(() => Scan(model: scanModel));
      } else {
        model.errors = productData["errors"];
        if (productData["errors"] != null) {
          Helper.messageDialog(
              Get.context!,
              model.errors![0].errorCode ?? "Try again!!",
              model.errors![0].errorDescription ?? "Something went wrong");
        }
      }
    }
  }).catchError((error) {
    ConditionalLogs().customLog("$error");
    Helper.close();
    MainController mainController = Get.put(MainController());
    mainController.showErrorPopup();
  });
}