Skip to main content
Glama
test-net-costs.cjs5.3 kB
const axios = require('axios'); async function testNetCosts() { 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-09-01'; const endDate = '2025-10-07'; const apiKey = `${userKey}:${ACCOUNT_KEY}:${DIVISION_ID}`; console.log('═'.repeat(80)); console.log('TEST 1: Regular Unblended Costs (v2 API)'); console.log('═'.repeat(80)); const test1 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: { startDate, endDate, isUnblended: true, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }, headers: { 'Authorization': token, 'apikey': apiKey } }); // V2 API has wrapper: { data: [...], nextToken: ... } const value1 = test1.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${value1.toFixed(2)}`); console.log(`Breakdown: ${test1.data.data.map(d => `${d.usage_date}: $${d.total_cost.toFixed(2)}`).join(', ')}`); console.log(''); console.log('═'.repeat(80)); console.log('TEST 2: Net Amortized Costs (v2 API with isNetAmortized=true)'); console.log('═'.repeat(80)); const test2 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: { startDate, endDate, isNetAmortized: true, // KEY FLAG costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }, headers: { 'Authorization': token, 'apikey': apiKey } }); const value2 = test2.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${value2.toFixed(2)}`); console.log(`Breakdown: ${test2.data.data.map(d => `${d.usage_date}: $${d.total_cost.toFixed(2)}`).join(', ')}`); console.log(''); console.log('═'.repeat(80)); console.log('TEST 3: WITHOUT isNetAmortized flag (should show different value)'); console.log('═'.repeat(80)); const test3 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: { startDate, endDate, // NO isNetAmortized flag - just defaults costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }, headers: { 'Authorization': token, 'apikey': apiKey } }); const value3 = test3.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${value3.toFixed(2)}`); console.log(`Breakdown: ${test3.data.data.map(d => `${d.usage_date}: $${d.total_cost.toFixed(2)}`).join(', ')}`); console.log(''); console.log('═'.repeat(80)); console.log('TEST 4: Net Unblended Costs (v2 API with isNetUnblended=true)'); console.log('═'.repeat(80)); const test4 = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: { startDate, endDate, isNetUnblended: true, // KEY FLAG costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }, headers: { 'Authorization': token, 'apikey': apiKey } }); const value4 = test4.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${value4.toFixed(2)}`); console.log(`Breakdown: ${test4.data.data.map(d => `${d.usage_date}: $${d.total_cost.toFixed(2)}`).join(', ')}`); console.log(''); console.log('═'.repeat(80)); console.log('SUMMARY'); console.log('═'.repeat(80)); console.log(`Regular Unblended: $${value1.toFixed(2)}`); console.log(`Net Amortized: $${value2.toFixed(2)}`); console.log(`Without Flag: $${value3.toFixed(2)}`); console.log(`Net Unblended: $${value4.toFixed(2)}`); console.log(''); const diff1 = Math.abs(value1 - value2); const diff2 = Math.abs(value1 - value4); if (diff1 > 0.01) { console.log(`✅ isNetAmortized FLAG MAKES A DIFFERENCE: $${diff1.toFixed(2)} difference`); } else { console.log(`❌ isNetAmortized FLAG HAS NO EFFECT (diff: $${diff1.toFixed(2)})`); } if (diff2 > 0.01) { console.log(`✅ isNetUnblended FLAG MAKES A DIFFERENCE: $${diff2.toFixed(2)} difference`); } else { console.log(`❌ isNetUnblended FLAG HAS NO EFFECT (diff: $${diff2.toFixed(2)})`); } } 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)); } } } testNetCosts();

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