import { apiService } from './api.service';
import { underscoreToCamelcase } from './utils/camelcase-convert';
import axios from 'axios';

export const projectService = {
  async getUser() {
    return apiService.get(`/api/v3/user`);
  },

  async getProject(namespace, projectName) {
    return (await apiService.get(
      `/webapi/projects/${namespace}/${projectName}/`
    ))
  },

  async getFileBlob(projectsId, owner,options={}) {
    const res = await axios.get(`/${owner}/${projectsId}/sub_entries.json`,{params:options});  
    return res.data.entries.content;  
  },


  async getLanguages(
    projectId,
    params
  ) {
    return (await apiService.get(
      `/api/v4/projects/42422/languages`,
      params,
      {
        disableResponseConvert: true,
      }
    )) 
  },

  async bulkChangeFiles(
    projectsId, owner,data
  ) {
    const res = await axios.post(`/v1/${owner}/${projectsId}/contents/batch`,data);
    return res;
  },
};
