reorganizes api endpoints

This commit is contained in:
2019-10-11 16:07:09 +02:00
parent 3a1f8ec4f6
commit 068b2e7169
4 changed files with 145 additions and 136 deletions

View File

@@ -18,7 +18,7 @@ export const Api = {
.then(r => r.json())
},
fetchPlayerList () {
return fetch(API_ENDPOINT("players/all"))
return fetch(API_ENDPOINT("players/"))
.then(r => r.json())
},
fetchInventory () {
@@ -30,7 +30,7 @@ export const Api = {
.then(r => r.json())
},
fetchLoot (playerId) {
return fetch(API_ENDPOINT("players/loot/" + playerId))
return fetch(API_ENDPOINT("players/" + playerId + "/loot"))
.then(r => r.json())
},
putClaim (player_id, item_id) {
@@ -43,15 +43,15 @@ export const Api = {
},
updateWealth (player_id, value_in_gp) {
const payload = { player_id, value_in_gp: Number(value_in_gp) };
return this.__doFetch("players/update-wealth", 'PUT', payload);
return this.__doFetch("players/" + player_id + "/wealth", 'PUT', payload);
},
buyItems (player_id, items) {
const payload = { player_id, items };
return this.__doFetch("players/buy", 'POST', payload);
return this.__doFetch("players/" + player_id + "/loot", 'PUT', payload);
},
sellItems (player_id, items) {
const payload = { player_id, items };
return this.__doFetch("players/sell", 'POST', payload);
return this.__doFetch("players/" + player_id + "/loot", 'DELETE', payload);
},
newLoot (items) {
return this.__doFetch("admin/add-loot", 'POST', items);