@veryfi/veryfi-sdk 1.4.4 → 1.4.8

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.
@@ -0,0 +1,29 @@
1
+ const Client = require('../client/constructor');
2
+ /**
3
+ * Classify a document and extract all the fields from it. https://docs.veryfi.com/api/classify/classify-a-document/
4
+ * @example
5
+ * veryfi_client.classify_document_from_base64('base64_encoded_string',
6
+ * 'receipt.png',
7
+ * {'extra': 'parameters'})
8
+ *
9
+ * @memberof Client
10
+ * @param {String} base64_encoded_string Buffer string of a file to submit for classify extraction
11
+ * @param {String} file_name The file name including the extension
12
+ * @param {Object} kwargs Additional request parameters
13
+ * @returns {JSON} Data extracted from the document
14
+ */
15
+ Client.prototype.classify_document_from_base64 = async function (
16
+ base64_encoded_string,
17
+ file_name,
18
+ {...kwargs} = {}
19
+ ) {
20
+
21
+ let endpoint_name = "/classify/";
22
+ let request_arguments = {
23
+ "file_name": file_name,
24
+ "file_data": base64_encoded_string,
25
+ };
26
+ request_arguments = Object.assign(request_arguments, kwargs);
27
+ let document = await this._request("POST", endpoint_name, request_arguments, null, false);
28
+ return document['data'];
29
+ }
@@ -0,0 +1,26 @@
1
+ const Client = require('../client/constructor');
2
+ /**
3
+ * Classify document from url and extract all the fields from it. https://docs.veryfi.com/api/classify/classify-a-document/
4
+ * @example
5
+ * veryfi_client.classify_document_from_url('https://cdn.example.com/receipt.jpg')
6
+ *
7
+ * @memberof Client
8
+ * @param {string|null} file_url Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. "https://cdn.example.com/receipt.jpg".
9
+ * @param {Array} file_urls Required if file_url isn't specified. List of publicly accessible URLs to multiple files, e.g. ["https://cdn.example.com/receipt1.jpg", "https://cdn.example.com/receipt2.jpg"]
10
+ * @param {Object} kwargs Additional request parameters
11
+ * @return {JSON} Data extracted from the document.
12
+ */
13
+ Client.prototype.classify_document_from_url = async function (
14
+ file_url = null,
15
+ file_urls = null,
16
+ {...kwargs} = {},
17
+ ) {
18
+ let endpoint_name = "/classify/";
19
+ let request_arguments = {
20
+ "file_url": file_url,
21
+ "file_urls": file_urls,
22
+ };
23
+ request_arguments = Object.assign(request_arguments, kwargs);
24
+ let response = await this._request("POST", endpoint_name, request_arguments, null, false);
25
+ return response['data'];
26
+ }
@@ -27,6 +27,8 @@ require('../checks/processCheck');
27
27
  require('../checks/processCheckBase64');
28
28
  require('../checks/processCheckStream');
29
29
  require('../checks/processCheckUrl');
30
+ require('../classify/classifyDocumentBase64');
31
+ require('../classify/classifyDocumentUrl');
30
32
  require('../documents/deleteDocument');
31
33
  require('../documents/getDocument');
32
34
  require('../documents/getDocuments');
@@ -37,8 +39,13 @@ require('../documents/processDocumentUrl');
37
39
  require('../documents/updateDocument');
38
40
  require('../documents/tags/addTags');
39
41
  require('../documents/tags/addTag');
42
+ require('../documents/tags/deleteTag');
40
43
  require('../documents/tags/deleteTags');
41
44
  require('../documents/tags/replaceTags');
45
+ require('../split/splitDocumentBase64');
46
+ require('../split/splitDocumentUrl');
47
+ require('../split/getSplitDocument');
48
+ require('../split/getSplitDocuments');
42
49
  require('../w2s/deleteW2');
43
50
  require('../w2s/getW2');
44
51
  require('../w2s/getW2s');
@@ -8,7 +8,7 @@ const Client = require('../client/constructor');
8
8
  */
9
9
  Client.prototype._get_headers = function (has_files = false) {
10
10
  let final_headers = {
11
- "User-Agent": "Node.js Veryfi-Nodejs/1.4.4",
11
+ "User-Agent": "Node.js Veryfi-Nodejs/1.4.8",
12
12
  "Accept": "application/json",
13
13
  "Content-Type": "application/json",
14
14
  "Client-Id": this.client_id,
@@ -0,0 +1,13 @@
1
+ const Client = require('../../client/constructor');
2
+ /**
3
+ * Unlink a tag from a document. https://docs.veryfi.com/api/receipts-invoices/unlink-a-tag-from-a-document/
4
+ *
5
+ * @param {string} document_id ID of the document you'd like to unlink the tag from
6
+ * @param {string} tag_id ID of the tag you'd like to unlink
7
+ * @return {JSON} response about the unlinked tag.
8
+ */
9
+ Client.prototype.delete_tag = async function (document_id, tag_id) {
10
+ let endpoint_name = `/documents/${document_id}/tags/${tag_id}/`;
11
+ let request_arguments = {};
12
+ return this._request("DELETE", endpoint_name, request_arguments);
13
+ }
@@ -0,0 +1,14 @@
1
+ const Client = require('../client/constructor');
2
+ /**
3
+ * Veryfi's Get a Documents from PDF endpoint allows you to retrieve a collection of previously processed documents. https://docs.veryfi.com/api/receipts-invoices/get-documents-from-pdf/
4
+ * @memberof Client
5
+ * @param {string} document_id ID of the document you'd like to retrieve
6
+ * @param {Object} kwargs Additional request parameters
7
+ * @returns {JSON} Data extracted from the Document
8
+ */
9
+ Client.prototype.get_split_document = async function (document_id, {...kwargs} = {}) {
10
+ let endpoint_name = `/documents-set//${document_id}/`;
11
+ let request_arguments = {"id": document_id};
12
+ let document = await this._request("GET", endpoint_name, request_arguments, kwargs, false);
13
+ return document['data'];
14
+ }
@@ -0,0 +1,25 @@
1
+ const Client = require('../client/constructor');
2
+ /**
3
+ * Veryfi's Get a Submitted PDF endpoint allows you to retrieve a collection of previously processed documents. https://docs.veryfi.com/api/receipts-invoices/get-submitted-pdf/
4
+ * @memberof Client
5
+ * @param {number} page The page number. The response is capped to maximum of 50 results per page.
6
+ * @param {number} page_size The number of Documents per page.
7
+ * @param {Object} kwargs Additional request parameters
8
+ * @returns {JSON} JSON object of previously processed documents
9
+ */
10
+ Client.prototype.get_split_documents = async function (
11
+ page = 1,
12
+ page_size = 50,
13
+ {...kwargs} = {}
14
+ ) {
15
+ let endpoint_name = "/documents-set/";
16
+ let request_arguments = {
17
+ "page": page,
18
+ "page_size": page_size
19
+ };
20
+ let documents = await this._request("GET", endpoint_name, request_arguments, kwargs, false);
21
+ if ("data" in documents) {
22
+ documents = documents["data"];
23
+ }
24
+ return documents;
25
+ }
@@ -0,0 +1,29 @@
1
+ const Client = require('../client/constructor');
2
+ /**
3
+ * Split document PDF from url and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
4
+ * @example
5
+ * veryfi_client.split_document_from_base64('base64_encoded_string',
6
+ * 'receipt.png',
7
+ * {'extra': 'parameters'})
8
+ *
9
+ * @memberof Client
10
+ * @param {String} base64_encoded_string Buffer string of a file to submit for classify extraction
11
+ * @param {String} file_name The file name including the extension
12
+ * @param {Object} kwargs Additional request parameters
13
+ * @returns {JSON} Data extracted from the document
14
+ */
15
+ Client.prototype.split_document_from_base64 = async function (
16
+ base64_encoded_string,
17
+ file_name,
18
+ {...kwargs} = {}
19
+ ) {
20
+
21
+ let endpoint_name = "/documents-set/";
22
+ let request_arguments = {
23
+ "file_name": file_name,
24
+ "file_data": base64_encoded_string,
25
+ };
26
+ request_arguments = Object.assign(request_arguments, kwargs);
27
+ let document = await this._request("POST", endpoint_name, request_arguments, null, false);
28
+ return document['data'];
29
+ }
@@ -0,0 +1,26 @@
1
+ const Client = require('../client/constructor');
2
+ /**
3
+ * Split document PDF from url and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
4
+ * @example
5
+ * veryfi_client.split_document_from_url('https://cdn.example.com/receipts.pdf')
6
+ *
7
+ * @memberof Client
8
+ * @param {string|null} file_url Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. "https://cdn.example.com/receipt.jpg".
9
+ * @param {Array} file_urls Required if file_url isn't specified. List of publicly accessible URLs to multiple files, e.g. ["https://cdn.example.com/receipt1.jpg", "https://cdn.example.com/receipt2.jpg"]
10
+ * @param {Object} kwargs Additional request parameters
11
+ * @return {JSON} Data extracted from the document.
12
+ */
13
+ Client.prototype.split_document_from_url = async function (
14
+ file_url = null,
15
+ file_urls = null,
16
+ {...kwargs} = {},
17
+ ) {
18
+ let endpoint_name = "/documents-set/";
19
+ let request_arguments = {
20
+ "file_url": file_url,
21
+ "file_urls": file_urls
22
+ };
23
+ request_arguments = Object.assign(request_arguments, kwargs);
24
+ let response = await this._request("POST", endpoint_name, request_arguments, null, false);
25
+ return response['data'];
26
+ }
@@ -45,6 +45,95 @@ export declare class Client {
45
45
  */
46
46
  public _request(http_verb: String, endpoint_name: String, request_arguments: Object, params: Object, has_files: boolean): Promise<any>;
47
47
 
48
+ /**
49
+ * Classify a document. https://docs.veryfi.com/api/classify/classify-a-document/
50
+ * @example
51
+ * veryfi_client.classify_document_from_base64('base64_encoded_string',
52
+ * 'receipt.png',
53
+ * {'extra': 'parameters'})
54
+ *
55
+ * @memberof Client
56
+ * @param {String} base64_encoded_string Buffer string of a file to submit for classify and data extraction
57
+ * @param {String} file_name The file name including the extension
58
+ * @param {Object} kwargs Additional request parameters
59
+ * @returns {JSON} JSON of document classification
60
+ */
61
+ public classify_document_from_base64(
62
+ base64_encoded_string: string,
63
+ file_name: string,
64
+ {...kwargs}?: VeryfiExtraArgs
65
+ ): Promise<JsonObject>;
66
+
67
+ /**
68
+ * Classify document. https://docs.veryfi.com/api/receipts-invoices/process-a-document/
69
+ * @memberof Client
70
+ * @param {string} file_url Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. 'https://cdn.example.com/receipt.jpg'.
71
+ * @param {string[]} file_urls Required if file_url isn't specified. List of publicly accessible URLs to multiple files, e.g. ['https://cdn.example.com/receipt1.jpg', 'https://cdn.example.com/receipt2.jpg']
72
+ * @param {VeryfiExtraArgs} kwargs Additional request parameters
73
+ * @returns {JSON} JSON of document classification
74
+ */
75
+ public classify_document_from_url(
76
+ file_url?: string,
77
+ file_urls?: string[],
78
+ {...kwargs}?: VeryfiExtraArgs
79
+ ): Promise<JsonObject>;
80
+
81
+ /**
82
+ * Veryfi's PDF Splitter allows you to split a multipage PDF with different receipts and invoices inside into multiple Documents. This API supports .pdf,.zip. Min file size is 250bytes. The max pdf file size is 50mb. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
83
+ * @memberof Client
84
+ * @param {string} file_url Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. 'https://cdn.example.com/receipt.jpg'.
85
+ * @param {string[]} file_urls Required if file_url isn't specified. List of publicly accessible URLs to multiple files, e.g. ['https://cdn.example.com/receipt1.jpg', 'https://cdn.example.com/receipt2.jpg']
86
+ * @param {VeryfiExtraArgs} kwargs Additional request parameters
87
+ * @returns {JSON} JSON of document classification
88
+ */
89
+ public split_document_from_url(
90
+ file_url?: string,
91
+ file_urls?: string[],
92
+ {...kwargs}?: VeryfiExtraArgs
93
+ ): Promise<JsonObject>;
94
+
95
+ /**
96
+ * Veryfi's PDF Splitter allows you to split a multipage PDF with different receipts and invoices inside into multiple Documents. This API supports .pdf,.zip. Min file size is 250bytes. The max pdf file size is 50mb. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
97
+ * @example
98
+ * veryfi_client.split_document_from_base64('base64_encoded_string',
99
+ * 'receipt.png',
100
+ * {'extra': 'parameters'})
101
+ *
102
+ * @memberof Client
103
+ * @param {String} base64_encoded_string Buffer string of a file to submit for classify and data extraction
104
+ * @param {String} file_name The file name including the extension
105
+ * @param {Object} kwargs Additional request parameters
106
+ * @returns {JSON} JSON of document classification
107
+ */
108
+ public split_document_from_base64(
109
+ base64_encoded_string: string,
110
+ file_name: string,
111
+ {...kwargs}?: VeryfiExtraArgs
112
+ ): Promise<JsonObject>;
113
+
114
+ /**
115
+ * Veryfi's Get a Documents from PDF endpoint allows you to retrieve a collection of previously processed documents. https://docs.veryfi.com/api/receipts-invoices/get-documents-from-pdf/
116
+ * @memberof Client
117
+ * @param {string} document_id ID of the document you'd like to retrieve
118
+ * @param {Object} kwargs Additional request parameters
119
+ * @returns {Promise<JsonObject>} Object of data extracted from the document
120
+ */
121
+ public get_split_document(document_id: string,
122
+ {...kwargs}?: VeryfiExtraArgs): Promise<JsonObject>;
123
+
124
+ /**
125
+ * Veryfi's Get a Submitted PDF endpoint allows you to retrieve a collection of previously processed documents. https://docs.veryfi.com/api/receipts-invoices/get-submitted-pdf/
126
+ * @memberof Client
127
+ * @param {number} page The page number. The response is capped to maximum of 50 results per page.
128
+ * @param {number} page_size The number of Documents per page.
129
+ * @param {Object} kwargs Additional request parameters
130
+ * @returns {Promise<JsonObject>} Object of previously processed documents
131
+ */
132
+ public get_split_documents(
133
+ page?: number,
134
+ page_size?: number,
135
+ {...kwargs}?: VeryfiExtraArgs
136
+ ): Promise<JsonObject>;
48
137
 
49
138
  /**
50
139
  * Delete document from Veryfi. https://docs.veryfi.com/api/receipts-invoices/delete-a-document/
@@ -1015,6 +1104,16 @@ export declare class Client {
1015
1104
  */
1016
1105
  public delete_tags(document_id: string): Promise<any>;
1017
1106
 
1107
+ /**
1108
+ * Unlink a tag from a document. https://docs.veryfi.com/api/receipts-invoices/unlink-a-tag-from-a-document/
1109
+ *
1110
+ * @memberof Client
1111
+ * @param {string} document_id ID of the document you'd like to unlink the tag from
1112
+ * @param {string} tag_id ID of the tag you'd like to unlink
1113
+ * @return {Promise<any>} response about the unlinked tag.
1114
+ */
1115
+ public delete_tag(document_id: string, tag_id: string): Promise<any>;
1116
+
1018
1117
  /**
1019
1118
  * Add multiple tags on an existing document. https://docs.veryfi.com/api/receipts-invoices/add-tags-to-a-document/
1020
1119
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veryfi/veryfi-sdk",
3
- "version": "1.4.4",
3
+ "version": "1.4.8",
4
4
  "description": "Node.js module for communicating with the Veryfi OCR API",
5
5
  "main": "lib/client/client.js",
6
6
  "typings": "lib/types/Client.ts",
@@ -25,22 +25,25 @@
25
25
  "test": "test"
26
26
  },
27
27
  "devDependencies": {
28
- "jest": "^29.0.0",
29
- "jsdoc": "^4.0.3",
28
+ "jest": "^30.4.2",
29
+ "jsdoc": "^4.0.5",
30
30
  "minami": "^1.2.3",
31
- "ts-jest": "^29.0.1",
32
- "typescript": "^4.8.3"
31
+ "ts-jest": "^29.4.12",
32
+ "typescript": "^5.9.3"
33
33
  },
34
34
  "dependencies": {
35
- "@jest/globals": "^29.0.3",
36
- "axios": "^1.8.2",
37
- "docdash": "^1.2.0",
38
- "form-data": "^4.0.0",
39
- "jest-config": "^29.0.3"
35
+ "@jest/globals": "^30.4.1",
36
+ "axios": "^1.19.0",
37
+ "docdash": "^2.0.2",
38
+ "form-data": "^4.0.6",
39
+ "jest-config": "^30.4.2"
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",
43
- "url": "git+https://github.com/veryfi/veryfi-nodejs.git"
43
+ "url": "https://github.com/veryfi/veryfi-nodejs"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
44
47
  },
45
48
  "keywords": [
46
49
  "nodejs",