@veryfi/veryfi-sdk 1.4.4 → 1.4.6
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/lib/classify/classifyDocumentBase64.js +29 -0
- package/lib/classify/classifyDocumentUrl.js +26 -0
- package/lib/client/client.js +6 -0
- package/lib/client/getHeaders.js +1 -1
- package/lib/split/getSplitDocument.js +14 -0
- package/lib/split/getSplitDocuments.js +25 -0
- package/lib/split/splitDocumentBase64.js +29 -0
- package/lib/split/splitDocumentUrl.js +26 -0
- package/lib/types/Client.ts +89 -0
- package/package.json +1 -1
|
@@ -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
|
+
}
|
package/lib/client/client.js
CHANGED
|
@@ -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');
|
|
@@ -39,6 +41,10 @@ require('../documents/tags/addTags');
|
|
|
39
41
|
require('../documents/tags/addTag');
|
|
40
42
|
require('../documents/tags/deleteTags');
|
|
41
43
|
require('../documents/tags/replaceTags');
|
|
44
|
+
require('../split/splitDocumentBase64');
|
|
45
|
+
require('../split/splitDocumentUrl');
|
|
46
|
+
require('../split/getSplitDocument');
|
|
47
|
+
require('../split/getSplitDocuments');
|
|
42
48
|
require('../w2s/deleteW2');
|
|
43
49
|
require('../w2s/getW2');
|
|
44
50
|
require('../w2s/getW2s');
|
package/lib/client/getHeaders.js
CHANGED
|
@@ -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.
|
|
11
|
+
"User-Agent": "Node.js Veryfi-Nodejs/1.4.6",
|
|
12
12
|
"Accept": "application/json",
|
|
13
13
|
"Content-Type": "application/json",
|
|
14
14
|
"Client-Id": this.client_id,
|
|
@@ -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
|
+
}
|
package/lib/types/Client.ts
CHANGED
|
@@ -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/
|