Skip to main content
Glama
test-unblended-direct.cjs4.22 kB
const axios = require('axios'); async function testUnblendedDirect() { const BASE_URL = 'https://api.dev.umbrellacost.dev/api'; const USERNAME = 'elisha+testmcpdev@anodot.com'; const PASSWORD = 'Test123!'; const ACCOUNT_KEY = '111111639'; const DIVISION_ID = '0'; try { console.log('🔐 Authenticating...\n'); const authResponse = await axios.post(`${BASE_URL}/v1/users/signin`, { username: USERNAME, password: PASSWORD }); const token = authResponse.data.jwtToken; const tokenPayload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString()); const userKey = tokenPayload.sub; console.log('✅ Authenticated'); console.log(`User Key: ${userKey}\n`); const startDate = '2025-01-01'; const endDate = '2025-10-08'; const apiKey = `${userKey}:${ACCOUNT_KEY}:${DIVISION_ID}`; // Test 1: WITH isUnblended=true console.log('═'.repeat(80)); console.log('TEST 1: WITH isUnblended=true'); console.log('═'.repeat(80)); const params1 = { startDate, endDate, isUnblended: true, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }; console.log('Request params:', JSON.stringify(params1, null, 2)); console.log(''); const response1 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: params1, headers: { 'Authorization': token, 'apikey': apiKey } }); if (response1.data.data && response1.data.data.length > 0) { console.log(`Jan 2025: $${response1.data.data[0].total_cost.toFixed(2)}`); } // Test 2: WITHOUT any cost calculation flag (should default to unblended) console.log('\n' + '═'.repeat(80)); console.log('TEST 2: WITHOUT any cost calculation flag (API default behavior)'); console.log('═'.repeat(80)); const params2 = { startDate, endDate, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }; console.log('Request params:', JSON.stringify(params2, null, 2)); console.log(''); const response2 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: params2, headers: { 'Authorization': token, 'apikey': apiKey } }); if (response2.data.data && response2.data.data.length > 0) { console.log(`Jan 2025: $${response2.data.data[0].total_cost.toFixed(2)}`); } // Test 3: WITH isAmortized=true (to confirm difference) console.log('\n' + '═'.repeat(80)); console.log('TEST 3: WITH isAmortized=true (for comparison)'); console.log('═'.repeat(80)); const params3 = { startDate, endDate, isAmortized: true, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }; console.log('Request params:', JSON.stringify(params3, null, 2)); console.log(''); const response3 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: params3, headers: { 'Authorization': token, 'apikey': apiKey } }); if (response3.data.data && response3.data.data.length > 0) { console.log(`Jan 2025: $${response3.data.data[0].total_cost.toFixed(2)}`); } console.log('\n' + '═'.repeat(80)); console.log('SUMMARY'); console.log('═'.repeat(80)); console.log(`Unblended (with flag): $${response1.data.data[0].total_cost.toFixed(2)}`); console.log(`No flag (API default): $${response2.data.data[0].total_cost.toFixed(2)}`); console.log(`Amortized (with flag): $${response3.data.data[0].total_cost.toFixed(2)}`); if (Math.abs(response1.data.data[0].total_cost - response2.data.data[0].total_cost) < 1) { console.log('\n✅ Unblended with flag matches API default behavior'); } else { console.log('\n⚠️ Unblended with flag DIFFERS from API default!'); } } catch (error) { console.error('❌ Error:', error.message); if (error.response) { console.error('Status:', error.response.status); console.error('Data:', JSON.stringify(error.response.data, null, 2)); } } } testUnblendedDirect();

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