inventory and prop support

This commit is contained in:
Natsumi
2025-06-17 08:16:34 +12:00
parent adea1c083f
commit eaca05a485
10 changed files with 263 additions and 6 deletions

View File

@@ -21,6 +21,8 @@ import inviteMessagesRequest from './inviteMessages';
import imageRequest from './image';
import miscRequest from './misc';
import groupRequest from './group';
import inventoryRequest from './inventory';
import propRequest from './prop';
window.request = {
userRequest,
@@ -37,7 +39,9 @@ window.request = {
inviteMessagesRequest,
imageRequest,
miscRequest,
groupRequest
groupRequest,
inventoryRequest,
propRequest
};
export {
@@ -55,5 +59,7 @@ export {
inviteMessagesRequest,
imageRequest,
miscRequest,
groupRequest
groupRequest,
inventoryRequest,
propRequest
};

74
src/api/inventory.js Normal file
View File

@@ -0,0 +1,74 @@
const inventoryReq = {
/**
* @param {{ inventoryId: string }} params
* @returns {Promise<{json: any, params}>}
*/
getInventoryItem(params) {
return window.API.call(`inventory/${params.inventoryId}`, {
method: 'GET',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
},
/**
* @param {{ n: number, offset: number, order: string, types: string }} params
* @returns {Promise<{json: any, params}>}
*/
getInventoryItems(params) {
return window.API.call('inventory', {
method: 'GET',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
},
/**
* @param {{ inventoryId: string }} params
* @returns {Promise<{json: any, params}>}
*/
consumeInventoryBundle(params) {
return window.API.call(`inventory/${params.inventoryId}/consume`, {
method: 'PUT',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
},
/**
* @param {{ inventoryTemplateId: string }} params
* @returns {Promise<{json: any, params}>}
*/
getInventoryTemplate(params) {
return window.API.call(
`inventory/template/${params.inventoryTemplateId}`,
{
method: 'GET',
params
}
).then((json) => {
const args = {
json,
params
};
return args;
});
}
};
export default inventoryReq;

20
src/api/prop.js Normal file
View File

@@ -0,0 +1,20 @@
const propReq = {
/**
* @param {{ propId: string }} params
* @returns {Promise<{json: any, params}>}
*/
getProp(params) {
return window.API.call(`props/${params.propId}`, {
method: 'GET',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
}
};
export default propReq;