Skip to content

Instantly share code, notes, and snippets.

@brybrophy
Last active January 1, 2018 22:07
Show Gist options
  • Save brybrophy/b60ab6db58128b8c8a0b072713280e92 to your computer and use it in GitHub Desktop.
Save brybrophy/b60ab6db58128b8c8a0b072713280e92 to your computer and use it in GitHub Desktop.
export default class UsersApi {
constructor(apiCore, basePath) {
this._apiCore = apiCore;
this._basePath = `${basePath}/users`;
}
getAll() {
return this._apiCore.get(this._basePath);
}
getOne(userId) {
return this._apiCore.get(`${this._basePath}/${userId}`);
}
create(newUser) {
return this._apiCore.post(`${this._basePath}`, newUser);
}
update(userId, nextUser) {
return this._apiCore.put(`${this._basePath}/${userId}`, nextUser);
}
destroy(userId) {
return this._apiCore.delete(`${this._basePath}/${userId}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment