initila commit
This commit is contained in:
27
src/reprocess/reprocess.ts
Normal file
27
src/reprocess/reprocess.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { apiAxiosInstance } from "../service";
|
||||
|
||||
export type ReprocessItemValues = {
|
||||
typeID: number;
|
||||
buy: number;
|
||||
buy_reprocess: number;
|
||||
sell: number;
|
||||
sell_reprocess: number;
|
||||
}
|
||||
|
||||
export const reprocess = async (items: string, minerals: string, efficiency?: number): Promise<ReprocessItemValues[]> => {
|
||||
if (!items || !minerals || (efficiency && (efficiency < 0 || efficiency > 1))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const itemsJson = JSON.parse(items);
|
||||
const mineralsJson = JSON.parse(minerals);
|
||||
const sourceJson = {
|
||||
"ep_items": itemsJson,
|
||||
"ep_mat": mineralsJson
|
||||
};
|
||||
const source = JSON.stringify(sourceJson);
|
||||
|
||||
const response = await apiAxiosInstance.post('/reprocess', source, {params: {efficiency: efficiency ?? 0.55}});
|
||||
|
||||
return response.data;
|
||||
};
|
||||
Reference in New Issue
Block a user