import apiClient from "@/infrastructure/apiClient";
import callPath from "@/infrastructure/apiPaths/callPathPath";

export default {
  async search(searchModel) {
    const params = JSON.parse(JSON.stringify(searchModel));
    return await apiClient
      .post(callPath.search, params)
      .then((r) => r.data)
      .catch((e) => {
        throw e;
      });
  },
  async createOrUpdate(model) {
    const params = JSON.parse(JSON.stringify(model));
    return await apiClient
      .post(callPath.createOrUpdate, params)
      .then((r) => r.data)
      .catch((e) => {
        throw e;
      });
  },
  async getById(id) {
    return await apiClient
      .get(callPath.getById + id)
      .then((r) => r.data)
      .catch((e) => {
        throw e;
      });
  },
  async delete(id) {
    var result = await apiClient
      .delete(callPath.delete + id)
      .then((r) => {
        return r.data;
      })
      .catch((e) => {
        console.log(e);
        return {};
      });
    return result;
  },
};
