added missing endpoints

This commit is contained in:
balzack 2024-08-11 01:55:42 +02:00
parent 103438b28a
commit 79c37761a9
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import axios from 'redaxios';
export async function clearLogin(node: string, secure: boolean, token: string, all: boolean): Promise<void> {
const param = all ? '&all=true' : ''
const endpoint = `http${secure ? 's' : ''}://${node}/account/apps?agent=${token}${param}`;
const response = await axios.delete(endpoint);
if (response.status >= 400 && response.stateus < 600) {
throw new Error('clearLogin failed');
}
}

View File

@ -0,0 +1,14 @@
import axios from 'redaxios';
export async function getAvailable(node: string, secure: boolean): number {
const endpoint = `http${secure ? 's' : ''}://${node}/account/available`;
const response = await axios.get(endpoint);
if (response.status >= 400 && response.status < 600) {
throw new Error('getAvailable fetch failed');
}
if (typeof response.data !== 'number') {
throw new Error('getAvailable response failed');
}
return response.data;
}