import "./index.es78.js";
import e from "./index.es79.js";
class s {
  /**
   * Allows for static configuration of the axios object.
   *
   * @param callback
   */
  static configure(t) {
    t(e);
  }
  /**
   * Constructs a new BaseService object. This constructor should never be used directly.
   */
  constructor() {
    if (this.constructor === s)
      throw new TypeError('Abstract class "BaseService" cannot be instantiated directly.');
  }
  /**
   * Calls the POST /api/<resource>/ endpoint with the passed item.
   *
   * @param item
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  create(t) {
    const r = this.getTransform();
    return e.post(this.getBaseUrl(), r.toPayload(t), this.getConfig());
  }
  /**
   * Calls the DELETE /api/<resource>/:id endpoint for the passed item.
   *
   * @param item
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  delete(t) {
    return e.delete(`${this.getBaseUrl()}/${t.id}`);
  }
  /**
   * Calls the GET /api/<resource>/ endpoint.
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  fetchAll(t) {
    return e.get(this.getBaseUrl(), { params: t });
  }
  /**
   * Calls the GET /api/<resource>/:id endpoint.
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  fetchOne(t) {
    return e.get(`${this.getBaseUrl()}/${t}`);
  }
  /**
   * Calls the create/update API endpoint for the passed item.
   *
   * @param item
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  save(t) {
    return t.id ? this.update(t) : this.create(t);
  }
  /**
   * Calls the POST /api/<resource>/search endpoint.
   *
   * @param params
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  search(t) {
    return e.post(`${this.getBaseUrl()}/search`, t);
  }
  /**
   * Calls the PUT /api/<resource>/:id endpoint with the passed item.
   *
   * @param item
   *
   * @returns {Promise<AxiosResponse<T>>}
   */
  update(t) {
    const r = this.getTransform();
    return e.put(`${this.getBaseUrl()}/${t.id}`, r.toPayload(t), this.getConfig());
  }
  // protected
  /**
   * Returns the axios instance.
   *
   * @returns {AxiosStatic}
   */
  getAxios() {
    return e;
  }
  /**
   * Returns the API base URL string.
   */
  getBaseUrl() {
    return "";
  }
  /**
   * Returns the config properties for POST/PUT requests.
   *
   * @returns {null}
   */
  getConfig() {
    return null;
  }
  /**
   * Returns the transform object. This class will be used to generate the object sent on POST/PUT requests.
   */
  getTransform() {
    return {};
  }
}
export {
  s as default
};
//# sourceMappingURL=index.es15.js.map
