@veryfi/veryfi-sdk 1.2.4 → 1.3.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 +4 -1
- package/lib/main.js +29 -1
- package/lib/types/main.d.ts +159 -100
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ You may need to run the above command with `sudo`.
|
|
|
38
38
|
|
|
39
39
|
### Obtaining Client ID and user keys
|
|
40
40
|
|
|
41
|
-
If you don't have an account with Veryfi, please go ahead and register here: [https://
|
|
41
|
+
If you don't have an account with Veryfi, please go ahead and register here: [https://app.veryfi.com/signup/api/](https://app.veryfi.com/signup/api/)
|
|
42
42
|
|
|
43
43
|
### Node.js API Client Library
|
|
44
44
|
|
|
@@ -248,11 +248,14 @@ veryfi_client.update_document(id=12345,
|
|
|
248
248
|
```
|
|
249
249
|
|
|
250
250
|
## Need help?
|
|
251
|
+
Visit https://docs.veryfi.com/ to access integration guides and usage notes in the Veryfi API Documentation Portal
|
|
251
252
|
|
|
252
253
|
If you run into any issue or need help installing or using the library, please contact support@veryfi.com.
|
|
253
254
|
|
|
254
255
|
If you found a bug in this library or would like new features added, then open an issue or pull requests against this repo!
|
|
255
256
|
|
|
257
|
+
### [API Docs](https://docs.veryfi.com/)
|
|
258
|
+
|
|
256
259
|
### [Learn more at our blog](https://www.veryfi.com/nodejs/)
|
|
257
260
|
|
|
258
261
|
## Tutorial Video
|
package/lib/main.js
CHANGED
|
@@ -67,7 +67,7 @@ Client.prototype._check_w2_version = function () {
|
|
|
67
67
|
*/
|
|
68
68
|
Client.prototype._get_headers = function (has_files = false) {
|
|
69
69
|
let final_headers = {
|
|
70
|
-
"User-Agent": "Node.js Veryfi-Nodejs/1.
|
|
70
|
+
"User-Agent": "Node.js Veryfi-Nodejs/1.3.0",
|
|
71
71
|
"Accept": "application/json",
|
|
72
72
|
"Content-Type": "application/json",
|
|
73
73
|
"Client-Id": this.client_id,
|
|
@@ -535,6 +535,34 @@ Client.prototype.delete_tags = async function (document_id) {
|
|
|
535
535
|
return this._request("DELETE", endpoint_name, request_arguments);
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
+
/**
|
|
539
|
+
* Replace multiple tags on an existing document
|
|
540
|
+
*
|
|
541
|
+
* @param {number} document_id ID of the document you'd like to add a Tag
|
|
542
|
+
* @param {string[]} tags array of tags to be added
|
|
543
|
+
* @return {JSON} response about tag added.
|
|
544
|
+
*/
|
|
545
|
+
Client.prototype.replace_tags = async function (document_id, tags) {
|
|
546
|
+
let endpoint_name = `/documents/${document_id}/`;
|
|
547
|
+
let request_arguments = {"tags": tags};
|
|
548
|
+
let response = await this._request("PUT", endpoint_name, request_arguments);
|
|
549
|
+
return response['data'];
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Add multiple tags on an existing document
|
|
554
|
+
*
|
|
555
|
+
* @param {number} document_id ID of the document you'd like to add a Tag
|
|
556
|
+
* @param {string[]} tags array of tags to be added
|
|
557
|
+
* @return {JSON} response about tag added.
|
|
558
|
+
*/
|
|
559
|
+
Client.prototype.add_tags = async function (document_id, tags) {
|
|
560
|
+
let endpoint_name = `/documents/${document_id}/tags/`;
|
|
561
|
+
let request_arguments = {"tags": tags};
|
|
562
|
+
let response = await this._request("POST", endpoint_name, request_arguments);
|
|
563
|
+
return response['data'];
|
|
564
|
+
}
|
|
565
|
+
|
|
538
566
|
|
|
539
567
|
// Exports
|
|
540
568
|
|
package/lib/types/main.d.ts
CHANGED
|
@@ -4,124 +4,149 @@ import fs from "fs";
|
|
|
4
4
|
* Additional request parameters type
|
|
5
5
|
*/
|
|
6
6
|
export declare type VeryfiExtraArgs = Record<
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
string | number | symbol,
|
|
8
|
+
string | number | boolean
|
|
9
9
|
>;
|
|
10
10
|
|
|
11
|
+
export declare type BoundingElement = {
|
|
12
|
+
bounding_box?: null | number[];
|
|
13
|
+
bounding_region?: null | number[];
|
|
14
|
+
rotation?: null | number;
|
|
15
|
+
value?: null | number | string;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
/**
|
|
12
19
|
* Object of data extracted from the document
|
|
13
20
|
*/
|
|
14
21
|
export declare type VeryfiDocument = {
|
|
15
|
-
abn_number?: null | string;
|
|
16
|
-
account_number?: null | string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
abn_number?: null | string | BoundingElement;
|
|
23
|
+
account_number?: null | string | BoundingElement;
|
|
24
|
+
accounting_entry_type?: null | string;
|
|
25
|
+
balance?: null | string | BoundingElement;
|
|
26
|
+
barcodes?: null | string[] | BoundingElement[];
|
|
27
|
+
bill_to?: null | BillTo;
|
|
28
|
+
card_number?: null | string | BoundingElement;
|
|
29
|
+
cashback?: null | number | BoundingElement;
|
|
30
|
+
category?: null | string | BoundingElement;
|
|
31
|
+
created_date?: null | string;
|
|
32
|
+
currency_code?: null | string | BoundingElement;
|
|
33
|
+
custom_fields?: null | VeryfiExtraArgs;
|
|
34
|
+
date?: null | string | BoundingElement;
|
|
35
|
+
default_category?: null | string | BoundingElement;
|
|
36
|
+
delivery_date?: null | string | BoundingElement;
|
|
37
|
+
delivery_note_number?: null | string | BoundingElement;
|
|
38
|
+
discount?: null | number | BoundingElement;
|
|
39
|
+
document_reference_number?: null | string | BoundingElement;
|
|
40
|
+
document_title?: null | string | BoundingElement;
|
|
41
|
+
document_type?: null | string | BoundingElement;
|
|
42
|
+
due_date?: null | string | BoundingElement;
|
|
32
43
|
duplicate_of?: null | number;
|
|
44
|
+
exch_rate?: null | number;
|
|
33
45
|
external_id?: null | string;
|
|
46
|
+
final_balance?: null | number | BoundingElement;
|
|
47
|
+
guest_count?: null | number | BoundingElement;
|
|
34
48
|
id?: null | number;
|
|
49
|
+
img_blur?: null | boolean;
|
|
35
50
|
img_file_name?: null | string;
|
|
36
51
|
img_thumbnail_url?: null | string;
|
|
37
52
|
img_url?: null | string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
incoterms?: null | number | BoundingElement;
|
|
54
|
+
insurance?: null | number | BoundingElement;
|
|
55
|
+
invoice_number?: null | string | BoundingElement;
|
|
56
|
+
is_approved?: null | boolean;
|
|
57
|
+
is_blurry?: null | boolean[];
|
|
58
|
+
is_document?: null | boolean;
|
|
59
|
+
is_duplicate?: null | boolean;
|
|
60
|
+
is_money_in?: null | boolean | BoundingElement;
|
|
61
|
+
license_plate_number?: null | string | BoundingElement;
|
|
41
62
|
line_items?: null | LineItem[];
|
|
63
|
+
line_items_with_scores?: null | LineItem[];
|
|
42
64
|
notes?: null | string;
|
|
43
65
|
ocr_text?: null | string;
|
|
44
|
-
order_date?: null | string;
|
|
66
|
+
order_date?: null | string | BoundingElement;
|
|
45
67
|
payment?: null | Payment;
|
|
46
|
-
payment_display_name?: null | string;
|
|
47
|
-
payment_terms?: null | string;
|
|
48
|
-
payment_type?: null | string;
|
|
49
68
|
pdf_url?: null | string;
|
|
50
|
-
|
|
51
|
-
purchase_order_number?: null | string;
|
|
52
|
-
rounding?: null | number;
|
|
69
|
+
previous_balance?: null | number | BoundingElement;
|
|
70
|
+
purchase_order_number?: null | string | BoundingElement;
|
|
71
|
+
rounding?: null | number | BoundingElement;
|
|
72
|
+
server_name?: null | string | BoundingElement;
|
|
53
73
|
service_end_date?: null | string;
|
|
54
74
|
service_start_date?: null | string;
|
|
55
|
-
ship_date?: null | string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
store_number?: null | string;
|
|
60
|
-
subtotal?: null | number;
|
|
61
|
-
|
|
75
|
+
ship_date?: null | string | BoundingElement;
|
|
76
|
+
ship_to?: null | ShipTo;
|
|
77
|
+
shipping?: null | number | BoundingElement;
|
|
78
|
+
status?: null | string;
|
|
79
|
+
store_number?: null | string | BoundingElement;
|
|
80
|
+
subtotal?: null | number | BoundingElement;
|
|
81
|
+
tags?: null | Tag[];
|
|
82
|
+
tax?: null | number | BoundingElement;
|
|
62
83
|
tax_lines?: null | TaxLine[];
|
|
63
|
-
tip?: null | number;
|
|
64
|
-
total?: null | number;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
tip?: null | number | BoundingElement;
|
|
85
|
+
total?: null | number | BoundingElement;
|
|
86
|
+
total_pages?: null | number;
|
|
87
|
+
total_quantity?: null | string | BoundingElement;
|
|
88
|
+
total_weight?: null | string | BoundingElement;
|
|
89
|
+
tracking_number?: null | string | BoundingElement;
|
|
90
|
+
tracking_numbers?: null | BoundingElement[];
|
|
91
|
+
updated_date?: null | string;
|
|
92
|
+
vending_person?: null | string | BoundingElement;
|
|
93
|
+
vending_person_number?: null | string | BoundingElement;
|
|
68
94
|
vat_number?: null | string;
|
|
69
95
|
vendor?: null | Vendor;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
vendor_iban?: null | string;
|
|
96
|
+
vendors?: null | BoundingElement[];
|
|
97
|
+
vin_number?: null | string | BoundingElement;
|
|
98
|
+
warnings?: null | string[];
|
|
99
|
+
weights?: null | BoundingElement[];
|
|
75
100
|
};
|
|
76
101
|
|
|
77
102
|
declare type LineItem = {
|
|
78
|
-
date?: null | string;
|
|
79
|
-
description?: null | string;
|
|
80
|
-
discount?: null | number;
|
|
81
|
-
end_date?: null | string;
|
|
103
|
+
date?: null | string | BoundingElement;
|
|
104
|
+
description?: null | string | BoundingElement;
|
|
105
|
+
discount?: null | number | BoundingElement;
|
|
106
|
+
end_date?: null | string | BoundingElement;
|
|
82
107
|
hsn?: null | string;
|
|
83
108
|
id?: null | number;
|
|
84
109
|
order?: null | number;
|
|
85
|
-
price?: null | number;
|
|
86
|
-
quantity?: null | number;
|
|
87
|
-
reference?: null | string;
|
|
110
|
+
price?: null | number | BoundingElement;
|
|
111
|
+
quantity?: null | number | BoundingElement;
|
|
112
|
+
reference?: null | string | BoundingElement;
|
|
88
113
|
section?: null | string;
|
|
89
|
-
sku?: null | string;
|
|
114
|
+
sku?: null | string | BoundingElement;
|
|
90
115
|
start_date?: null | string;
|
|
91
116
|
tags?: null | null[];
|
|
92
|
-
tax?: null | number;
|
|
117
|
+
tax?: null | number| BoundingElement;
|
|
93
118
|
tax_rate?: null | number;
|
|
94
|
-
total?: null | number;
|
|
119
|
+
total?: null | number | BoundingElement;
|
|
95
120
|
type?: null | string;
|
|
96
121
|
unit_of_measure?: null | string;
|
|
97
122
|
};
|
|
98
123
|
|
|
99
124
|
declare type TaxLine = {
|
|
100
|
-
base?: null | number;
|
|
101
|
-
name?: null | string;
|
|
125
|
+
base?: null | number | BoundingElement;
|
|
126
|
+
name?: null | string | BoundingElement;
|
|
102
127
|
order?: null | number;
|
|
103
|
-
rate?: null | number;
|
|
104
|
-
total?: null | number;
|
|
128
|
+
rate?: null | number | BoundingElement;
|
|
129
|
+
total?: null | number | BoundingElement;
|
|
105
130
|
};
|
|
106
131
|
|
|
107
132
|
declare type Vendor = {
|
|
108
|
-
address?: null | string;
|
|
109
|
-
category?: null | string;
|
|
110
|
-
email?: null | string;
|
|
111
|
-
fax_number?: null | string;
|
|
112
|
-
name?: null | string;
|
|
113
|
-
phone_number?: null | string;
|
|
133
|
+
address?: null | string | BoundingElement;
|
|
134
|
+
category?: null | string | BoundingElement;
|
|
135
|
+
email?: null | string | BoundingElement;
|
|
136
|
+
fax_number?: null | string | BoundingElement;
|
|
137
|
+
name?: null | string | BoundingElement;
|
|
138
|
+
phone_number?: null | string | BoundingElement;
|
|
114
139
|
raw_name?: null | string;
|
|
115
|
-
vendor_logo?: null | string;
|
|
116
|
-
vendor_reg_number?: null | string;
|
|
140
|
+
vendor_logo?: null | string | BoundingElement;
|
|
141
|
+
vendor_reg_number?: null | string | BoundingElement;
|
|
117
142
|
vendor_type?: null | string;
|
|
118
|
-
web?: null | string;
|
|
143
|
+
web?: null | string | BoundingElement;
|
|
119
144
|
};
|
|
120
145
|
|
|
121
146
|
declare type Payment = {
|
|
122
|
-
card_number?: null | string;
|
|
123
|
-
display_name?: null | string;
|
|
124
|
-
terms?: null | number;
|
|
147
|
+
card_number?: null | string | BoundingElement;
|
|
148
|
+
display_name?: null | string | BoundingElement;
|
|
149
|
+
terms?: null | number | BoundingElement;
|
|
125
150
|
type?: null | string;
|
|
126
151
|
};
|
|
127
152
|
|
|
@@ -130,6 +155,22 @@ declare type Tag = {
|
|
|
130
155
|
name?: null | string;
|
|
131
156
|
};
|
|
132
157
|
|
|
158
|
+
declare type BillTo = {
|
|
159
|
+
address?: null | string | BoundingElement;
|
|
160
|
+
email?: null | string | BoundingElement;
|
|
161
|
+
name?: null | string | BoundingElement;
|
|
162
|
+
parsed_address?: null | string;
|
|
163
|
+
phone_number?: null | number | string | BoundingElement;
|
|
164
|
+
reg_number?: null | number | string | BoundingElement;
|
|
165
|
+
vat_number?: null | number | string | BoundingElement;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
declare type ShipTo = {
|
|
169
|
+
address?: null | string | BoundingElement;
|
|
170
|
+
name?: null | string | BoundingElement;
|
|
171
|
+
parsed_address?: null | string;
|
|
172
|
+
};
|
|
173
|
+
|
|
133
174
|
export declare class Client {
|
|
134
175
|
/**
|
|
135
176
|
* Create instance of a Client
|
|
@@ -143,13 +184,13 @@ export declare class Client {
|
|
|
143
184
|
* @param {number} timeout
|
|
144
185
|
*/
|
|
145
186
|
constructor(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
187
|
+
client_id: string,
|
|
188
|
+
client_secret: string | undefined,
|
|
189
|
+
username: string,
|
|
190
|
+
api_key: string,
|
|
191
|
+
base_url?: string,
|
|
192
|
+
api_version?: string,
|
|
193
|
+
timeout?: number
|
|
153
194
|
);
|
|
154
195
|
|
|
155
196
|
client_id: string;
|
|
@@ -256,10 +297,10 @@ export declare class Client {
|
|
|
256
297
|
* @returns {Promise<VeryfiDocument>} Object of data extracted from the document
|
|
257
298
|
*/
|
|
258
299
|
public process_document(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
300
|
+
file_path: string,
|
|
301
|
+
categories?: string[],
|
|
302
|
+
delete_after_processing?: boolean,
|
|
303
|
+
{ ...kwargs }?: VeryfiExtraArgs
|
|
263
304
|
): Promise<VeryfiDocument>;
|
|
264
305
|
|
|
265
306
|
/**
|
|
@@ -276,14 +317,14 @@ export declare class Client {
|
|
|
276
317
|
* @return {Promise<VeryfiDocument>} Object of data extracted from the document
|
|
277
318
|
*/
|
|
278
319
|
public process_document_url(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
320
|
+
file_url?: string,
|
|
321
|
+
file_urls?: string[],
|
|
322
|
+
categories?: string[],
|
|
323
|
+
delete_after_processing?: boolean,
|
|
324
|
+
boost_mode?: number,
|
|
325
|
+
external_id?: string,
|
|
326
|
+
max_pages_to_process?: number,
|
|
327
|
+
{ ...kwargs }?: VeryfiExtraArgs
|
|
287
328
|
): Promise<VeryfiDocument>;
|
|
288
329
|
|
|
289
330
|
/**
|
|
@@ -307,8 +348,8 @@ export declare class Client {
|
|
|
307
348
|
* @return {Promise<VeryfiDocument>} Object of data extracted from the document with updated fields, if fields are writable. Otherwise, a document with unchanged fields.
|
|
308
349
|
*/
|
|
309
350
|
public update_document(
|
|
310
|
-
|
|
311
|
-
|
|
351
|
+
document_id: string,
|
|
352
|
+
{ ...kwargs }?: VeryfiExtraArgs
|
|
312
353
|
): Promise<VeryfiDocument>;
|
|
313
354
|
|
|
314
355
|
/**
|
|
@@ -328,6 +369,24 @@ export declare class Client {
|
|
|
328
369
|
*/
|
|
329
370
|
public delete_tags(document_id: string): Promise<any>;
|
|
330
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Add multiple tags on an existing document
|
|
374
|
+
*
|
|
375
|
+
* @param {number} document_id ID of the document you'd like to add a Tag
|
|
376
|
+
* @param {string[]} tags name to add
|
|
377
|
+
* @return {Promise<Tag>} response about tags added.
|
|
378
|
+
*/
|
|
379
|
+
public add_tags(document_id: string, tags: string[]): Promise<Tag>;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Replace multiple tags on an existing document
|
|
383
|
+
*
|
|
384
|
+
* @param {number} document_id ID of the document you'd like to add a Tag
|
|
385
|
+
* @param {string[]} tags names to be added
|
|
386
|
+
* @return {Promise<Tag>} response about tags added.
|
|
387
|
+
*/
|
|
388
|
+
public replace_tags(document_id: string, tags: string[]): Promise<Tag>;
|
|
389
|
+
|
|
331
390
|
}
|
|
332
391
|
|
|
333
392
|
/**
|
|
@@ -342,13 +401,13 @@ export declare class Client {
|
|
|
342
401
|
* @param {number} timeout
|
|
343
402
|
*/
|
|
344
403
|
export declare function Client(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
404
|
+
client_id: string,
|
|
405
|
+
client_secret: string | undefined,
|
|
406
|
+
username: string,
|
|
407
|
+
api_key: string,
|
|
408
|
+
base_url?: string,
|
|
409
|
+
api_version?: string,
|
|
410
|
+
timeout?: number
|
|
352
411
|
): Client;
|
|
353
412
|
|
|
354
413
|
export default Client;
|