import apiClient from "@/infrastructure/apiClient";
import apiPath from "@/infrastructure/apiPath";
export default {
  async search(searchModel) {
    const params = JSON.parse(JSON.stringify(searchModel));
    var searchResult = await apiClient
      .post(apiPath.scriptConfig.search, params)
      .then((r) => r.data)
      .catch((e) => {
        console.log(e);
        return {};
      });
    return searchResult;
  },
  async createOrUpdate(model) {
    const params = JSON.parse(JSON.stringify(model));
    var result = await apiClient
      .post(apiPath.scriptConfig.createOrUpdate, params)
      .then((r) => r.data)
      .catch((e) => {
        console.log(e);
        return {};
      });
    return result;
  },
  async getById(id) {
    var result = await apiClient
      .get(apiPath.scriptConfig.getById + id)
      .then((r) => r.data)
      .catch((e) => {
        console.log(e);
        return {};
      });
    return result;
  },
  async delete(id) {
    var result = await apiClient
      .delete(apiPath.scriptConfig.delete + id)
      .then((r) => r.data)
      .catch((e) => {
        console.log(e);
        return {};
      });
    return result;
  },
};
