2019-10-27 05:18:26 +00:00
|
|
|
/* global axios */
|
|
|
|
|
|
|
|
const API_VERSION = `/api/v1`;
|
|
|
|
|
|
|
|
class ApiClient {
|
|
|
|
constructor(url) {
|
2019-12-28 16:26:42 +00:00
|
|
|
this.apiVersion = API_VERSION;
|
|
|
|
this.url = `${this.apiVersion}/${url}`;
|
2019-10-27 05:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get() {
|
|
|
|
return axios.get(this.url);
|
|
|
|
}
|
|
|
|
|
|
|
|
show(id) {
|
|
|
|
return axios.get(`${this.url}/${id}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
create(data) {
|
|
|
|
return axios.post(this.url, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(id, data) {
|
|
|
|
return axios.patch(`${this.url}/${id}`, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete(id) {
|
|
|
|
return axios.delete(`${this.url}/${id}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ApiClient;
|