Add machine category lookup
This commit is contained in:
Vendored
+18
@@ -263,6 +263,21 @@ class AgrarmonitorConnector {
|
||||
}
|
||||
throw new Error('Ungueltige Agrarmonitor Kunden-API-Antwort');
|
||||
}
|
||||
async getMaschinenKategorien() {
|
||||
const response = await this.http.get('/maschinen/kategorien');
|
||||
await this.saveSession();
|
||||
const document = this.parseHtmlDocument(response.data);
|
||||
const rows = Array.from(document.querySelectorAll('table#kategorien tbody tr'));
|
||||
return rows.map(row => {
|
||||
const cells = Array.from(row.querySelectorAll('td'));
|
||||
return {
|
||||
id: this.parseNumber(row.id),
|
||||
name: cells[0]?.textContent?.trim() ?? '',
|
||||
zugmaschine: this.parseJaNein(cells[2]?.textContent ?? ''),
|
||||
mobilSichtbar: Boolean(cells[4]?.querySelector('input[type="checkbox"]')?.checked),
|
||||
};
|
||||
});
|
||||
}
|
||||
createHttpClient() {
|
||||
const client = (0, axios_cookiejar_support_1.wrapper)(axios_1.default.create({
|
||||
baseURL: this.baseUrl,
|
||||
@@ -441,6 +456,9 @@ class AgrarmonitorConnector {
|
||||
const numberValue = Number(String(value ?? '').trim());
|
||||
return Number.isFinite(numberValue) ? numberValue : 0;
|
||||
}
|
||||
parseJaNein(value) {
|
||||
return value.trim().toLowerCase() === 'ja';
|
||||
}
|
||||
parseGermanShortDate(value) {
|
||||
const match = value.trim().match(/^(\d{2})\.(\d{2})\.(\d{2})$/);
|
||||
if (!match) {
|
||||
|
||||
Reference in New Issue
Block a user