intifact 1.0.0
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 +148 -0
- package/dist/index.d.ts +1794 -0
- package/dist/index.js +191 -0
- package/dist/types.d.ts +3070 -0
- package/dist/types.js +5 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import createClient from "openapi-fetch";
|
|
2
|
+
export class Intifact {
|
|
3
|
+
client;
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
this.client = createClient({
|
|
6
|
+
baseUrl: opts.baseUrl ?? "https://api.intifact.com",
|
|
7
|
+
headers: { "x-api-key": opts.apiKey },
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
// ── Health ──
|
|
11
|
+
/** Verificar que la API está disponible */
|
|
12
|
+
health() {
|
|
13
|
+
return this.client.GET("/health");
|
|
14
|
+
}
|
|
15
|
+
// ── Facturas ──
|
|
16
|
+
/** Enviar una factura (01) o boleta (03) a SUNAT */
|
|
17
|
+
sendInvoice(body) {
|
|
18
|
+
return this.client.POST("/api/v1/invoice/send", { body: body });
|
|
19
|
+
}
|
|
20
|
+
/** Obtener el PDF de una factura/boleta */
|
|
21
|
+
getInvoicePdf(id) {
|
|
22
|
+
return this.client.GET("/api/v1/invoice/{id}/pdf", { params: { path: { id } } });
|
|
23
|
+
}
|
|
24
|
+
/** Obtener el XML firmado de una factura/boleta */
|
|
25
|
+
getInvoiceXml(id) {
|
|
26
|
+
return this.client.GET("/api/v1/invoice/{id}/xml", { params: { path: { id } } });
|
|
27
|
+
}
|
|
28
|
+
/** Obtener el CDR (constancia de recepción) de SUNAT */
|
|
29
|
+
getInvoiceCdr(id) {
|
|
30
|
+
return this.client.GET("/api/v1/invoice/{id}/cdr", { params: { path: { id } } });
|
|
31
|
+
}
|
|
32
|
+
/** Comunicar de baja una factura */
|
|
33
|
+
cancelInvoice(body) {
|
|
34
|
+
return this.client.POST("/api/v1/invoice/cancel", { body: body });
|
|
35
|
+
}
|
|
36
|
+
/** Comunicar de baja una boleta (resumen de bajas) */
|
|
37
|
+
cancelBoleta(body) {
|
|
38
|
+
return this.client.POST("/api/v1/boleta/cancel", { body: body });
|
|
39
|
+
}
|
|
40
|
+
// ── Notas de Crédito / Débito ──
|
|
41
|
+
/** Enviar una nota de crédito o débito */
|
|
42
|
+
sendNote(body) {
|
|
43
|
+
return this.client.POST("/api/v1/note/send", { body: body });
|
|
44
|
+
}
|
|
45
|
+
/** Obtener el PDF de una nota */
|
|
46
|
+
getNotePdf(id) {
|
|
47
|
+
return this.client.GET("/api/v1/note/{id}/pdf", { params: { path: { id } } });
|
|
48
|
+
}
|
|
49
|
+
/** Obtener el XML firmado de una nota */
|
|
50
|
+
getNoteXml(id) {
|
|
51
|
+
return this.client.GET("/api/v1/note/{id}/xml", { params: { path: { id } } });
|
|
52
|
+
}
|
|
53
|
+
// ── Guías de Remisión ──
|
|
54
|
+
/** Enviar una guía de remisión */
|
|
55
|
+
sendDespatch(body) {
|
|
56
|
+
return this.client.POST("/api/v1/despatch/send", { body: body });
|
|
57
|
+
}
|
|
58
|
+
/** Obtener el XML de una guía */
|
|
59
|
+
getDespatchXml(id) {
|
|
60
|
+
return this.client.GET("/api/v1/despatch/{id}/xml", { params: { path: { id } } });
|
|
61
|
+
}
|
|
62
|
+
/** Obtener el PDF de una guía */
|
|
63
|
+
getDespatchPdf(id) {
|
|
64
|
+
return this.client.GET("/api/v1/despatch/{id}/pdf", { params: { path: { id } } });
|
|
65
|
+
}
|
|
66
|
+
// ── Resúmenes y Anulaciones ──
|
|
67
|
+
/** Enviar un resumen diario de boletas */
|
|
68
|
+
sendSummary(body) {
|
|
69
|
+
return this.client.POST("/api/v1/summary/send", { body: body });
|
|
70
|
+
}
|
|
71
|
+
/** Enviar una comunicación de baja */
|
|
72
|
+
sendVoided(body) {
|
|
73
|
+
return this.client.POST("/api/v1/voided/send", { body: body });
|
|
74
|
+
}
|
|
75
|
+
/** Consultar el estado de un ticket (resumen/baja) */
|
|
76
|
+
getTicketStatus(ticket, query) {
|
|
77
|
+
return this.client.GET("/api/v1/ticket/{ticket}/status", { params: { path: { ticket }, query: query } });
|
|
78
|
+
}
|
|
79
|
+
// ── Documentos ──
|
|
80
|
+
/** Listar documentos emitidos (con filtros opcionales) */
|
|
81
|
+
listDocuments(query) {
|
|
82
|
+
return this.client.GET("/api/v1/documents", { params: { query: query } });
|
|
83
|
+
}
|
|
84
|
+
/** Obtener un documento por ID */
|
|
85
|
+
getDocument(id) {
|
|
86
|
+
return this.client.GET("/api/v1/documents/{id}", { params: { path: { id } } });
|
|
87
|
+
}
|
|
88
|
+
/** Reintentar el envío de un documento fallido */
|
|
89
|
+
retryDocument(id) {
|
|
90
|
+
return this.client.POST("/api/v1/documents/{id}/retry", { params: { path: { id } } });
|
|
91
|
+
}
|
|
92
|
+
/** Obtener el siguiente correlativo disponible */
|
|
93
|
+
getNextCorrelativo(query) {
|
|
94
|
+
return this.client.GET("/api/v1/documents/next-correlativo", { params: { query: query } });
|
|
95
|
+
}
|
|
96
|
+
// ── Colas ──
|
|
97
|
+
/** Obtener estadísticas de las colas de procesamiento */
|
|
98
|
+
getQueueStats() {
|
|
99
|
+
return this.client.GET("/api/v1/queues/stats");
|
|
100
|
+
}
|
|
101
|
+
// ── Empresas ──
|
|
102
|
+
/** Listar tus empresas registradas */
|
|
103
|
+
listCompanies() {
|
|
104
|
+
return this.client.GET("/api/v1/companies");
|
|
105
|
+
}
|
|
106
|
+
/** Registrar una nueva empresa */
|
|
107
|
+
createCompany(body) {
|
|
108
|
+
return this.client.POST("/api/v1/companies", { body: body });
|
|
109
|
+
}
|
|
110
|
+
/** Obtener los datos de una empresa */
|
|
111
|
+
getCompany(id) {
|
|
112
|
+
return this.client.GET("/api/v1/companies/{id}", { params: { path: { id } } });
|
|
113
|
+
}
|
|
114
|
+
/** Actualizar los datos de una empresa */
|
|
115
|
+
updateCompany(id, body) {
|
|
116
|
+
return this.client.PUT("/api/v1/companies/{id}", { params: { path: { id } }, body: body });
|
|
117
|
+
}
|
|
118
|
+
/** Subir el certificado digital (.pfx/.p12) de una empresa */
|
|
119
|
+
uploadCertificate(id, body) {
|
|
120
|
+
return this.client.POST("/api/v1/companies/{id}/certificate", { params: { path: { id } }, body: body });
|
|
121
|
+
}
|
|
122
|
+
/** Subir el logo de una empresa (aparece en PDFs) */
|
|
123
|
+
uploadLogo(id, body) {
|
|
124
|
+
return this.client.POST("/api/v1/companies/{id}/logo", { params: { path: { id } }, body: body });
|
|
125
|
+
}
|
|
126
|
+
/** Obtener el logo de una empresa */
|
|
127
|
+
getLogo(id) {
|
|
128
|
+
return this.client.GET("/api/v1/companies/{id}/logo", { params: { path: { id } } });
|
|
129
|
+
}
|
|
130
|
+
/** Eliminar el logo de una empresa */
|
|
131
|
+
deleteLogo(id) {
|
|
132
|
+
return this.client.DELETE("/api/v1/companies/{id}/logo", { params: { path: { id } } });
|
|
133
|
+
}
|
|
134
|
+
// ── Webhooks ──
|
|
135
|
+
/** Listar tus webhooks configurados */
|
|
136
|
+
listWebhooks() {
|
|
137
|
+
return this.client.GET("/api/v1/webhooks");
|
|
138
|
+
}
|
|
139
|
+
/** Crear un nuevo webhook */
|
|
140
|
+
createWebhook(body) {
|
|
141
|
+
return this.client.POST("/api/v1/webhooks", { body: body });
|
|
142
|
+
}
|
|
143
|
+
/** Obtener un webhook por ID */
|
|
144
|
+
getWebhook(id) {
|
|
145
|
+
return this.client.GET("/api/v1/webhooks/{id}", { params: { path: { id } } });
|
|
146
|
+
}
|
|
147
|
+
/** Actualizar un webhook */
|
|
148
|
+
updateWebhook(id, body) {
|
|
149
|
+
return this.client.PUT("/api/v1/webhooks/{id}", { params: { path: { id } }, body: body });
|
|
150
|
+
}
|
|
151
|
+
/** Eliminar un webhook */
|
|
152
|
+
deleteWebhook(id) {
|
|
153
|
+
return this.client.DELETE("/api/v1/webhooks/{id}", { params: { path: { id } } });
|
|
154
|
+
}
|
|
155
|
+
/** Listar entregas de un webhook */
|
|
156
|
+
listWebhookDeliveries(id, query) {
|
|
157
|
+
return this.client.GET("/api/v1/webhooks/{id}/deliveries", { params: { path: { id }, query: query } });
|
|
158
|
+
}
|
|
159
|
+
/** Re-enviar una entrega fallida */
|
|
160
|
+
redeliverWebhook(endpointId, deliveryId) {
|
|
161
|
+
return this.client.POST("/api/v1/webhooks/{id}/deliveries/{deliveryId}/redeliver", { params: { path: { id: endpointId, deliveryId } } });
|
|
162
|
+
}
|
|
163
|
+
/** Enviar un evento de prueba al webhook */
|
|
164
|
+
testWebhook(id) {
|
|
165
|
+
return this.client.POST("/api/v1/webhooks/{id}/test", { params: { path: { id } } });
|
|
166
|
+
}
|
|
167
|
+
// ── Uso ──
|
|
168
|
+
/** Obtener el consumo actual de tu plan */
|
|
169
|
+
getUsage() {
|
|
170
|
+
return this.client.GET("/api/v1/usage");
|
|
171
|
+
}
|
|
172
|
+
// ── Consulta Pública ──
|
|
173
|
+
/** Consultar un documento emitido (sin autenticación) */
|
|
174
|
+
consultarDocumento(ruc, tipoDoc, serie, numero) {
|
|
175
|
+
return this.client.GET("/api/v1/public/consultar/{ruc}/{tipoDoc}/{serie}/{numero}", {
|
|
176
|
+
params: { path: { ruc, tipoDoc, serie, numero } },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/** Obtener el PDF de un documento emitido (sin autenticación) */
|
|
180
|
+
consultarDocumentoPdf(ruc, tipoDoc, serie, numero) {
|
|
181
|
+
return this.client.GET("/api/v1/public/consultar/{ruc}/{tipoDoc}/{serie}/{numero}/pdf", {
|
|
182
|
+
params: { path: { ruc, tipoDoc, serie, numero } },
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/** Obtener el XML de un documento emitido (sin autenticación) */
|
|
186
|
+
consultarDocumentoXml(ruc, tipoDoc, serie, numero) {
|
|
187
|
+
return this.client.GET("/api/v1/public/consultar/{ruc}/{tipoDoc}/{serie}/{numero}/xml", {
|
|
188
|
+
params: { path: { ruc, tipoDoc, serie, numero } },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|