callSubmitAPI method

Future<void> callSubmitAPI(
  1. List<Map<String, dynamic>> request
)

Implementation

Future<void> callSubmitAPI(List<Map<String, dynamic>> request) async {
  BuildContext context = Get.context!;
  Helper.progressDialog(context, "Please wait..");
  dio
      .get(
    'https://run.mocky.io/v3/bf5e3f36-685a-4bc3-9ebd-9ec4d9d94389',
    data: {"fieldForceId": "123", " assetList": request},
    options: Options(
      headers: {
        'Authorization': 'Bearer Authorization',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    ),
  )
      .then((response) {
    Helper.close();
    if (response.data != null) {
      CollectStockSubmitModel model = CollectStockSubmitModel();
      ConditionalLogs().customLog("${response.data}");
      Map<String, dynamic> creditData = response.data;
      model = CollectStockSubmitModel.fromJson(creditData);
      if (model.status == true) {
        // Get.to(() => CollectStockSuccess(
        //       model: model.data!,
        //     ));
      } else {
        if (model.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();
  });
}