fiscalapi 4.0.0 → 4.0.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,10 +40,10 @@ Puedes usar el SDK tanto en aplicaciones Node.js tradicionales como en framework
|
|
|
40
40
|
1. **Crea tu objeto de configuración** con [tus credenciales](https://docs.fiscalapi.com/credentials-info):
|
|
41
41
|
```javascript
|
|
42
42
|
// CommonJS
|
|
43
|
-
const {
|
|
43
|
+
const { FiscalapiClient } = require('fiscalapi');
|
|
44
44
|
|
|
45
45
|
// o ESM
|
|
46
|
-
import {
|
|
46
|
+
import { FiscalapiClient } from 'fiscalapi';
|
|
47
47
|
|
|
48
48
|
const settings = {
|
|
49
49
|
apiUrl: "https://test.fiscalapi.com", // https://live.fiscalapi.com (producción)
|
|
@@ -54,10 +54,10 @@ Puedes usar el SDK tanto en aplicaciones Node.js tradicionales como en framework
|
|
|
54
54
|
|
|
55
55
|
2. **Crea la instancia del cliente**:
|
|
56
56
|
```javascript
|
|
57
|
-
const fiscalApi =
|
|
57
|
+
const fiscalApi = FiscalapiClient.create(settings);
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Para ejemplos completos, consulta [samples-
|
|
60
|
+
Para ejemplos completos, consulta [samples-express](https://github.com/FiscalAPI/fiscalapi-samples-express).
|
|
61
61
|
|
|
62
62
|
---
|
|
63
63
|
|
|
@@ -65,21 +65,23 @@ Para ejemplos completos, consulta [samples-nodejs](https://github.com/FiscalAPI/
|
|
|
65
65
|
|
|
66
66
|
1. **Agrega la configuración** en tu archivo de variables de entorno (`.env`):
|
|
67
67
|
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
FISCALAPI_API_KEY=<api_key>
|
|
69
|
+
FISCALAPI_TENANT=<tenant>
|
|
70
|
+
FISCALAPI_API_URL=https://test.fiscalapi.com
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
2. **Crea y registra el cliente** (por ejemplo, en un servicio o módulo):
|
|
74
|
+
|
|
74
75
|
```typescript
|
|
75
|
-
|
|
76
|
-
import {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
// services/fiscalapi.service.ts
|
|
77
|
+
import { FiscalapiClient } from 'fiscalapi'
|
|
78
|
+
import config from '../config/config';
|
|
79
|
+
|
|
80
|
+
export const createFiscalApiClient = () => {
|
|
81
|
+
return FiscalapiClient.create({
|
|
82
|
+
apiUrl: config.fiscalapiSettings.apiUrl,
|
|
83
|
+
apiKey: config.fiscalapiSettings.apiKey,
|
|
84
|
+
tenant: config.fiscalapiSettings.tenant
|
|
83
85
|
});
|
|
84
86
|
};
|
|
85
87
|
```
|
|
@@ -87,11 +89,13 @@ Para ejemplos completos, consulta [samples-nodejs](https://github.com/FiscalAPI/
|
|
|
87
89
|
En Express:
|
|
88
90
|
```javascript
|
|
89
91
|
// En tu controlador o router
|
|
90
|
-
|
|
92
|
+
import { createFiscalApiClient } from '../services/fiscalapi.service';
|
|
93
|
+
|
|
94
|
+
const fiscalapi = createFiscalApiClient();
|
|
91
95
|
|
|
92
96
|
app.post('/invoices', async (req, res) => {
|
|
93
97
|
try {
|
|
94
|
-
const response = await
|
|
98
|
+
const response = await fiscalapi.invoices.create(req.body);
|
|
95
99
|
res.json(response);
|
|
96
100
|
} catch (error) {
|
|
97
101
|
res.status(500).json({ error: error.message });
|
|
@@ -99,7 +103,7 @@ app.post('/invoices', async (req, res) => {
|
|
|
99
103
|
});
|
|
100
104
|
```
|
|
101
105
|
|
|
102
|
-
Para más ejemplos, revisa [samples-express](https://github.com/FiscalAPI/fiscalapi-samples-
|
|
106
|
+
Para más ejemplos, revisa [samples-express](https://github.com/FiscalAPI/fiscalapi-samples-express).
|
|
103
107
|
|
|
104
108
|
|
|
105
109
|
## 🔄 Modos de Operación
|
|
@@ -385,4 +389,4 @@ Este proyecto está licenciado bajo la Licencia **MPL-2.0**. Consulta el archivo
|
|
|
385
389
|
|
|
386
390
|
---
|
|
387
391
|
|
|
388
|
-
Desarrollado con ❤️ por [Fiscalapi](https://www.fiscalapi.com)
|
|
392
|
+
Desarrollado con ❤️ por [Fiscalapi](https://www.fiscalapi.com)
|