// import Vue from "vue";
// import axios from "axios";
// // import 'sweetalert2/dist/sweetalert2.min.css';
// import "assets/common/css/sweetalert2.min.css";

// const tfooter = '<a href="">در ارتباط با سرور مشکلی ایجاد شد</a>';
// const ApiService = {
//   init(baseURL) {
//     axios.defaults.baseURL = baseURL;
//     this.setHeader();
//   },
//   removeHeader() {
//     axios.defaults.headers.common = {};
//   },
//   setHeader() {
//     axios.defaults.headers.common["Authorization"] = getToken();
//     // axios.defaults.headers.common["lang"] = "fa";
//   },
//   get(
//     vue,
//     url,
//     callBack = null,
//     errorBk = null,
//     hasToast = false,
//     ttitle = "دریافت اطلاعات",
//     tbody = "انجام شد."
//   ) {
//     //axios.defaults.headers.common["lang"] = window.localStorage.getItem("lang");
//     return axios
//       .get(url)
//       .then((response) => {
//         if (hasToast && response) {
//           Vue.swal({
//             title: ttitle,
//             text: tbody,
//             icon: "success",
//             position: "bottom-end",
//             showConfirmButton: false,
//             toast: true,
//             timer: 2000,
//           });
//         }
//         if (callBack) callBack(response);
//       })
//       .catch((response) => {
//         // if (response.response.status == 401 && vue != null) {
//         //   vue.$store.dispatch(LOGOUT);
//         //   vue.$router.push({
//         //     name: "login"
//         //   });
//         // }
//         // Swal.fire({
//         //   title: ttitle,
//         //   text: response.response.message,
//         //   icon: "error",
//         //   position: "bottom-end",
//         //   footer: tfooter,
//         //   showConfirmButton: false,
//         //   toast: true,
//         //   timer: 2500
//         // });
//         if (errorBk) errorBk(response);
//       });
//   },
//   post(
//     vue,
//     url,
//     datas,
//     callBack = null,
//     errorBk = null,
//     hasToast = false,
//     ttitle = "ثبت اطلاعات",
//     tbody = "انجام شد."
//   ) {
//     var data = new FormData();
//     for (const [key, value] of Object.entries(datas)) data.append(key, value);
//     return axios
//       .post(url, data)
//       .then((response) => {
//         if (hasToast && response) {
//           Vue.swal({
//             title: ttitle,
//             text: tbody,
//             icon: "success",
//             position: "bottom-end",
//             showConfirmButton: false,
//             toast: true,
//             timer: 2000,
//           });
//         }
//         if (callBack) callBack(response);
//       })
//       .catch((response) => {
//         // if (response.response.status == 401 && vue != null) {
//         //   vue.$store.dispatch(LOGOUT);
//         //   vue.$router.push({
//         //     name: "login"
//         //   });
//         // }
//         // Swal.fire({
//         //   title: ttitle,
//         //   text: response.response.data.message,
//         //   icon: "error",
//         //   position: "bottom-end",
//         //   footer: tfooter,
//         //   showConfirmButton: false,
//         //   toast: true,
//         //   timer: 2500
//         // });
//         if (errorBk) errorBk(response);
//       });
//   },
//   getRequest(url, options = {}) {
//     return axios.get(url, options);
//   },
//   postRequest(url, data = [], options = {}) {
//     return axios.post(url, data, options);
//   },

//   formData(url, data = []) {
//     const formData = new FormData();
//     for (const [key, value] of Object.entries(data)) {
//       if (value !== undefined && value !== null) formData.append(key, value);
//     }

//     return axios.post(url, formData);
//   },
//   externalPostRequest(url, data = [], config = {}) {
//     const formData = new FormData();
//     for (const [key, value] of Object.entries(data))
//       formData.append(key, value);

//     return axios.post(url, formData, config);
//   },
//   put(url, data) {
//     return axios.put(url, data);
//   },
//   delete(url, guid) {
//     return axios.delete(url, { guid });
//   },
//   customRequest(data) {
//     return axios(data);
//   },
// };

// export default ApiService;