-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.mjs
More file actions
39 lines (32 loc) · 1.18 KB
/
Copy pathtest-api.mjs
File metadata and controls
39 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { CuenticaAPI } from './dist/api.js';
const api = new CuenticaAPI({ apiToken: process.env.CUENTICA_API_TOKEN });
async function test() {
try {
// Get an invoice to see structure
const invoices = await api.invoices.list({ page_size: 1 });
if (invoices.data.length > 0) {
const invoice = await api.invoices.get(invoices.data[0].id);
console.log('=== INVOICE STRUCTURE ===');
console.log(JSON.stringify(invoice, null, 2));
}
// Get a transfer to see structure
const transfers = await api.transfers.list({ page_size: 1 });
if (transfers.data.length > 0) {
console.log('=== TRANSFER STRUCTURE ===');
console.log(JSON.stringify(transfers.data[0], null, 2));
}
// Get an income to see structure
const incomes = await api.incomes.list({ page_size: 1 });
if (incomes.data.length > 0) {
console.log('=== INCOME STRUCTURE ===');
console.log(JSON.stringify(incomes.data[0], null, 2));
}
// Get accounts
const accounts = await api.accounts.list();
console.log('=== ACCOUNTS ===');
console.log(JSON.stringify(accounts.data, null, 2));
} catch (error) {
console.error('Error:', error);
}
}
test();