import { config } from 'dotenv'; config(); async function listLexOfficeArticles() { console.log('πŸ” Lade LexOffice Artikel...\n'); try { const response = await fetch('https://api.lexoffice.io/v1/articles?page=0&size=100', { method: 'GET', headers: { 'Authorization': `Bearer ${process.env.LEXOFFICE_API_KEY}`, 'Accept': 'application/json', }, }); if (!response.ok) { throw new Error(`LexOffice API Error: ${response.status}`); } const data = await response.json(); if (!data.content || data.content.length === 0) { console.log('⚠️ Keine Artikel gefunden.'); return; } console.log(`βœ… Gefunden: ${data.content.length} Artikel\n`); console.log('─'.repeat(80)); data.content.forEach((article: any, index: number) => { console.log(`\n${index + 1}. ${article.title || article.articleNumber || 'Unbekannt'}`); console.log(` ID: ${article.id}`); console.log(` Artikelnummer: ${article.articleNumber || 'N/A'}`); console.log(` Typ: ${article.type || 'N/A'}`); if (article.price) { console.log(` Preis: ${article.price.netAmount || 0}€ netto`); } if (article.description) { console.log(` Beschreibung: ${article.description.substring(0, 60)}...`); } }); console.log('\n' + '─'.repeat(80)); console.log('\nπŸ’‘ Kopieren Sie die IDs fΓΌr Ihr Produkt-Mapping!'); } catch (error: any) { console.error('❌ Fehler:', error.message); } } listLexOfficeArticles();