Skip to main content
Glama
verify-saola-exact.cjs6.87 kB
#!/usr/bin/env node const https = require('https'); const axios = require('axios'); const axiosInstance = axios.create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }), timeout: 30000 }); async function verifySaolaExact() { console.log('\n═══════════════════════════════════════════════════════════════'); console.log(' SAOLA VERIFICATION - EXACT QUERY FROM MANUAL_ANSWERS.txt'); console.log('═══════════════════════════════════════════════════════════════\n'); const baseUrl = 'https://api.umbrellacost.io/api/v1'; // Expected values from MANUAL_ANSWERS.txt const EXPECTED = { '2025-03': 104755.07426900661, '2025-04': 111340.42435642441, '2025-05': 149774.23802783, '2025-06': 165666.57014308573, '2025-07': 183920.57814672764 }; try { // Authenticate console.log('Authenticating as david+saola@umbrellacost.com...'); const authResponse = await axiosInstance.post(`${baseUrl}/users/signin`, { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' }); const token = authResponse.data.jwtToken; const tokenPayload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString()); const userKey = tokenPayload.username || tokenPayload.sub; console.log('✅ Authenticated. User Key:', userKey); // Build API key (account 9350 for SAOLA) const apiKey = `${userKey}:9350:0`; // EXACT parameters from MANUAL_ANSWERS.txt console.log('\n📊 Running EXACT query from MANUAL_ANSWERS.txt:'); console.log('Parameters:'); console.log(' startDate: 2025-03-01'); console.log(' endDate: 2025-07-31'); console.log(' groupBy: none'); console.log(' costType: ["cost", "discount"]'); console.log(' isUnblended: true'); console.log(' periodGranLevel: month'); // Query with exact parameters const params = new URLSearchParams({ startDate: '2025-03-01', endDate: '2025-07-31', groupBy: 'none', costType: 'cost', isUnblended: 'true', periodGranLevel: 'month' }); // Add discount as second costType params.append('costType', 'discount'); console.log('\n🔍 Sending request...'); const response = await axiosInstance.get(`${baseUrl}/invoices/caui?${params}`, { headers: { 'Authorization': token, 'apikey': apiKey } }); console.log('\n📋 ACTUAL RESPONSE:'); console.log('─────────────────────────────────────────'); console.log(JSON.stringify(response.data, null, 2)); // Now try with groupBy=usagedate to get monthly breakdown console.log('\n\n📊 Getting monthly breakdown (groupBy=usagedate):'); const params2 = new URLSearchParams({ startDate: '2025-03-01', endDate: '2025-07-31', groupBy: 'usagedate', costType: 'cost', isUnblended: 'true', periodGranLevel: 'month' }); params2.append('costType', 'discount'); const response2 = await axiosInstance.get(`${baseUrl}/invoices/caui?${params2}`, { headers: { 'Authorization': token, 'apikey': apiKey } }); console.log('\n📊 COMPARISON TABLE:'); console.log('═══════════════════════════════════════════════════════════'); console.log('Month │ Actual Cost │ Expected Cost │ Difference'); console.log('─────────────────────────────────────────────────────────────'); if (response2.data && Array.isArray(response2.data)) { response2.data.forEach(item => { const month = item.usage_date; const expected = EXPECTED[month]; if (expected) { const actual = item.total_cost; const diff = actual - expected; const pctDiff = ((diff / expected) * 100).toFixed(1); const monthName = { '2025-03': 'Mar 2025', '2025-04': 'Apr 2025', '2025-05': 'May 2025', '2025-06': 'Jun 2025', '2025-07': 'Jul 2025' }[month]; console.log(`${monthName} │ $${actual.toFixed(2).padEnd(15)} │ $${expected.toFixed(2).padEnd(15)} │ ${diff > 0 ? '+' : ''}$${diff.toFixed(2)} (${pctDiff}%)`); } }); } console.log('═══════════════════════════════════════════════════════════'); console.log('\n📝 ANALYSIS:'); if (response2.data && response2.data[0]) { const firstItem = response2.data[0]; const actualCost = firstItem.total_cost; const expectedCost = EXPECTED['2025-03']; const percentDiff = ((actualCost - expectedCost) / expectedCost * 100).toFixed(1); console.log(`Account ID: ${firstItem.account_id} (Expected: 932213950603) ${firstItem.account_id === '932213950603' ? '✅' : '❌'}`); console.log(`\nCost Difference: Actual costs are ${percentDiff}% higher than expected`); console.log('\nPossible reasons for difference:'); console.log('1. Tax might be included now (was excluded in MANUAL_ANSWERS.txt)'); console.log('2. Different cost calculation method (blended vs unblended)'); console.log('3. Additional fees or charges included'); console.log('4. Data might be from different time periods'); } } catch (error) { console.error('\n❌ Error:', error.message); if (error.response) { console.error('Response:', error.response.data); } } } verifySaolaExact().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server