-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathejemplo-timbres.ts
More file actions
42 lines (34 loc) · 1.4 KB
/
ejemplo-timbres.ts
File metadata and controls
42 lines (34 loc) · 1.4 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
40
41
42
import { FiscalapiClient, FiscalapiSettings } from '../src/index';
async function main(): Promise<void> {
// Configuración de FiscalAPI
const settings: FiscalapiSettings = {
apiUrl: 'https://test.fiscalapi.com', // https://live.fiscalapi.com
apiKey: '<api-key>', // API key de FiscalAPI
tenant: '<tenant>', // Tenant de FiscalAPI
debug: true // true, imprime raw request y response en consola, util durante el desarrollo de la integración.
};
const client = FiscalapiClient.create(settings);
// 1. Listar transacciones de timbres
const list = await client.stamps.getList(1, 10);
console.log('Lista de transacciones:', list);
// 2. Obtener transacción por ID
const transaction = await client.stamps.getById('77678d6d-94b1-4635-aa91-15cdd7423aab');
console.log('Transacción por ID:', transaction);
// 3. Transferir timbres
const transfer = await client.stamps.transferStamps({
fromPersonId: '2e7b988f-3a2a-4f67-86e9-3f931dd48581',
toPersonId: '5fd9f48c-a6a2-474f-944b-88a01751d432',
amount: 1,
comments: 'Transferencia de prueba'
});
console.log('Transferencia:', transfer);
// 4. Retirar timbres
const withdraw = await client.stamps.withdrawStamps({
fromPersonId: '5fd9f48c-a6a2-474f-944b-88a01751d432',
toPersonId: '2e7b988f-3a2a-4f67-86e9-3f931dd48581',
amount: 1,
comments: 'Retiro de prueba'
});
console.log('Retiro:', withdraw);
}
main();