callDealerDetailsApi method

Future<void> callDealerDetailsApi(
  1. int dealerId, {
  2. required bool isDealerFlow,
})

Implementation

Future<void> callDealerDetailsApi(int dealerId,
    {required bool isDealerFlow}) async {
  BuildContext context = Get.context!;
  // WidgetsBinding.instance.addPostFrameCallback((_) {
  //   Helper.progressDialog(context, "Please wait..");
  // });
  // printLogs(dio);
  await dio
      .get(
    '${ApiConstant.baseUrl}cpm-channel-partner-svc/partner/getMoreInfo/$dealerId',
    options: Options(
      headers: {
        'Content-Type': 'application/json',
      },
    ),
  )
      .then((response) {
    // Get.back();
    if (response.data != null) {
      print('dealerDetails$response.data');
      Map<String, dynamic> data = response.data;
      DealerDetailsModel model = DealerDetailsModel.fromJson(data);
      storage.write("DISTRIBUTER_ID", model.profile!.parentId ?? "");
      storage.write("REGION_ID", model.profile!.address!.locationId1 ?? "");
      storage.write("REGION_NAME",
          model.profile!.address!.locationName4 ?? ""); // region verify
      storage.write("LEVEL_NAME", model.profile!.levelName ?? "");
      storage.write("PARTNER_ID ", model.profile?.partnerId);
      partnerId = model.profile?.partnerId ?? '';
      storage.write("LEVEL_ID", model.profile!.levelId);
      storage.write("ADDRESS_ID", model.profile!.address!.id ?? "");
      if (isDealerFlow) {
        storage.write("DEALER_LEVEL_ID", model.profile!.levelId);
      }
      // if (model.profile!.profileGroup != null &&
      //     model.profile!.profileGroup!.company != null &&
      //     model.profile!.profileGroup!.company!.isNotEmpty) {
      //   for (int i = 0;
      //       i < model.profile!.profileGroup!.company!.length;
      //       i++) {
      //     if (model.profile!.profileGroup!.company![i].field ==
      //         'withHoldingPercentage') {
      //       if (model.profile!.profileGroup!.company![i].value != null) {
      //         List<String> taxValueCode =
      //             model.profile!.profileGroup!.company![i].value!.split("-");
      //         String taxValue = taxValueCode[1].replaceAll("%", "").trim();
      //         String taxCode = taxValueCode[0].trim();
      //         log("$taxValue $taxCode");
      //         storage.write("ADHOX_TAX_VALUE", taxValue);
      //         storage.write("ADHOX_TAX_CODE", taxValue);
      //       }
      //     }
      //   }
      // }
    }
  }, onError: (error) {
    print(error.toString());
    // Get.back();
    // Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}