callReservecreditSaleAPI method

Future<void> callReservecreditSaleAPI(
  1. double amount,
  2. List<Map<String, dynamic>> request
)

Implementation

Future<void> callReservecreditSaleAPI(
    double amount, List<Map<String, dynamic>> request) async {
  BuildContext context = Get.context!;
  Helper.progressDialog(context, "Please wait..");

  dio
      .get(
    'https://run.mocky.io/v3/04dba49c-ddd2-4c8b-bd82-33110740df02',
    data: {
      "partnerId": "123",
      "amount": amount,
      "txnType": "R",
      "referenceId": "1298"
    },
    options: Options(
      headers: {
        'Authorization': 'Bearer Authorization',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    ),
  )
      .then((response) async {
    Helper.close();
    if (response.data != null) {
      ReserveCreditSaleModel model = ReserveCreditSaleModel();
      ConditionalLogs().customLog("${response.data}");
      Map<String, dynamic> creditData = response.data;
      model = ReserveCreditSaleModel.fromJson(creditData);
      if (model.responseCode == "0") {
        await callSubmitAPI(request);
      } else {
        Helper.messageDialog(
            Get.context!,
            model.responseCode ?? "Try again!!",
            model.responseMessage ?? "Something went wrong");
      }
    }
  }).catchError((error) {
    ConditionalLogs().customLog("$error");
    Helper.close();
    MainController mainController = Get.put(MainController());
    mainController.showErrorPopup();
  });
}