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 {
    Get.back();
    if (response.data != null) {
      ReserveCreditSaleModel model = ReserveCreditSaleModel();
      if (kDebugMode) {
        print(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");
      }
    }
  }, onError: (error) {
    if (kDebugMode) {
      print(error.toString());
    }
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}