import { call, crud, download } from 'store/utils/api';
import { config } from 'config/general';

const api = {
  dynamicApi: (url: string, method: string): void => (options: {}): Promise =>
    call(url, method || 'POST', options),
  dynamicDownload: (url: string): ((object: {}) => Promise) => (options: {}): Promise =>
    download(url, options),
  dynamic: (name: string): {} => ({
    ...crud(name),
  }),
  dynamicLinked: (data: {}): {} => {
    const url = `${data.parentType}/${data.parentId}/${data.resourceType}`;
    return {
      ...crud(url),
    };
  },
};

export default api;
