totalum-api-sdk 2.0.25 → 2.0.26

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.
Files changed (2) hide show
  1. package/README.MD +55 -1
  2. package/package.json +1 -1
package/README.MD CHANGED
@@ -92,7 +92,7 @@ const result = await totalumClient.crud.getItems('your_element_table_name', {});
92
92
 
93
93
  ```html
94
94
  <head>
95
- <script src="https://cdn.jsdelivr.net/npm/totalum-api-sdk@2.0.23/dist/totalum-sdk.min.js"></script>
95
+ <script src="https://cdn.jsdelivr.net/npm/totalum-api-sdk@2.0.26/dist/totalum-sdk.min.js"></script>
96
96
  </head>
97
97
  <script>
98
98
  //Example of use TotalumSdk in your custom html page
@@ -459,6 +459,60 @@ const ocrResult = result.data.data;
459
459
 
460
460
  ```
461
461
 
462
+ ### scan an invoice (get the details of an invoice)
463
+
464
+ ```javascript
465
+
466
+ // you can only do scan of a file that is previously uploaded to totalum (see the upload file function)
467
+ // then you can do scan of the file using the file name of the file uploaded
468
+ const fileName = 'your_file_name.png'; // replace 'your_file_name' with the name of your file, replace .png with the extension of your file
469
+ const file = yourFileBlob // replace yourFile with your file object binary blob (in blob format)
470
+ const formData = new FormData();
471
+ formData.append('file', file, fileName);
472
+ const result = await totalumClient.files.uploadFile(formData);
473
+ const fileNameId = result.data.data;
474
+
475
+ const result = await totalumClient.files.scanInvoice(fileNameId);
476
+ const invoiceResult = result.data.data;
477
+
478
+ ```
479
+
480
+ ### scan a document (get the details of a document)
481
+
482
+ ```javascript
483
+
484
+ // first upload the file to totalum
485
+ const fileName = 'your_file_name.png'; // replace 'your_file_name' with the name of your file, replace .png with the extension of your file
486
+ const file = yourFileBlob // replace yourFile with your file object binary blob (in blob format)
487
+ const formData = new FormData();
488
+ formData.append('file', file, fileName);
489
+ const result = await totalumClient.files.uploadFile(formData);
490
+ const fileNameId = result.data.data;
491
+
492
+ // define the json properties that you want to extract from the document
493
+ // this is just an example, you can define your own properties following the JSON schema format, the api will return a json with the properties that you define here
494
+ const properties = {
495
+ "fecha": {
496
+ "type": "string",
497
+ "format": "date",
498
+ "description": "introduce here your description for help api to extract this value"
499
+ },
500
+ "import": {
501
+ "type": "number",
502
+ "description": "the import"
503
+ },
504
+ "currency": {
505
+ "type": "string",
506
+ "enum": ["EUR", "USD", "GBP", "OTHER"],
507
+ "description": "if currency is not EUR, USD or GBP set OTHER"
508
+ }
509
+ }
510
+
511
+ const result = await totalumClient.files.scanDocument(fileNameId, properties);
512
+ const documentResult = result.data.data;
513
+
514
+ ```
515
+
462
516
 
463
517
  ## Functions for call OpenAI API without need to have an OpenAI account
464
518
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totalum-api-sdk",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "description": "Totalum sdk wrapper and utils of totalum api",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",