import { APIBase } from '@dvn/core/api/apiBase';
export class SepetApi {
  constructor(endpoint, defaultHeaders = {}, defaultQueryParams = {}) {
    // region buckets
    this.createBucket = (data) => this.api.post('buckets', data);
    this.getBuckets = () => this.api.get('buckets');
    this.getBucket = (id) => this.api.get(`buckets/${id}`);
    this.getBucketVersionList = (id) => this.api.get(`buckets/${id}/versions`);
    this.updateBucket = (id, data) => this.api.put(`buckets/${id}`, data);
    this.deleteBucket = (id) => this.api.delete(`buckets/${id}`);
    // endregion
    // region files
    this.uploadFile = (domain, path, data) => {
      const formData = new FormData();
      formData.append(path, data);
      return this.api.post(domain, formData);
    };
    this.getFileList = (domain, path, version) => {
      const headers = {};
      if (version) {
        headers['bucket-version'] = version;
      }
      return this.api.get(`${domain}/${path}`, {}, headers);
    };
    this.deleteFileOrFolder = (domain, path) => this.api.delete(`${domain}/${path}`);
    this.api = new APIBase(endpoint, defaultHeaders);
    this.api.axios.defaults.params = defaultQueryParams;
  }
}
