import auth from './Auth'; import Http from './Http'; import { apiRouter } from './services'; export default class Rest extends Http { constructor(path) { super(auth); this.route = apiRouter.route(path); } find(id, query) { return this.request( 'GET', this._routeId(id), query, null, true ); } insert(data) { return this.request( 'POST', this.route, null, data, true ); } update(id, data) { return this.request( 'PUT', this._routeId(id), null, data, true ); } delete(id) { return this.request( 'DELETE', this._routeId(id), null, null, true ); } _routeId(id) { id = id || ''; return `${this.route}/${id}`; } }