callILoadPurchaseOrderApi method

Future<void> callILoadPurchaseOrderApi()

Implementation

Future<void> callILoadPurchaseOrderApi() async {
  BuildContext context = Get.context!;
  Helper.progressDialog(context, "");
  int? userID = int.parse(
    SingletonSotrage.secureStorageInterface.readSecureData(
          SecureStorageService.userId,
        ) ??
        "0",
  );
  try {
    await ApiClient(baseUrl: ApiConstant.posBaseUrl)
        .getILoadPurchaseOrder(
      xUserId: SingletonSotrage.secureStorageInterface.readSecureData(
            SecureStorageService.xUserId,
          ) ??
          "",
      userId: userID,
      transactionType: "SELL_OUT",
      transactionSubType: "ELOAD",
    )
        .then((response) async {
      EloadContextsResponse model = response;
      Helper.close();
      if (model.status == "POS200") {
        iLoadSelectList.value = model.data?.eload?.elementAtOrNull(0)?.denominations ?? [];
        configDetailsList.value = model.data?.configDetails ?? [];
        userType.value = (model.data?.userType ?? "").toString();
        levelId.value = (model.data?.sellerPartyMinDetails?.levelId ?? 5).toString();
        for (var info in model.data?.configDetails ?? []) {
          if (info.key == "eSimOfferId") {
            print("object ${info.value}");
          }
        }
        pogID.value = (iLoadSelectList.elementAtOrNull(0)?.pogId ?? "").toString();
        offerID.value = (iLoadSelectList.elementAtOrNull(0)?.offerId ?? "").toString();
        isLoadingAmountMore.value = true;
      } else {
        isLoadingAmountMore.value = true;
        Helper.messageDialog(
          Get.context!,
          model.errors?.elementAtOrNull(0)?.code ?? 'tryAgain'.tr,
          model.errors?.elementAtOrNull(0)?.localeMessage ?? 'somethingWrong'.tr,
        );
      }
    }).catchError((onError) {
      Helper.close();
      Helper.messageDialog(context, 'tryAgain'.tr, 'somethingWrong'.tr);
    });
  } catch (e, st) {
    Helper.close();
    if (kDebugMode) {
      print(st);
    }
  }
}