@veryfi/veryfi-sdk 1.3.1 → 1.4.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.
Files changed (83) hide show
  1. package/README.md +443 -145
  2. package/lib/anydocs/deleteAnyDocument.js +12 -0
  3. package/lib/anydocs/getAnyDocument.js +22 -0
  4. package/lib/anydocs/getAnyDocuments.js +30 -0
  5. package/lib/anydocs/processAnyDocument.js +33 -0
  6. package/lib/anydocs/processAnyDocumentBase64.js +31 -0
  7. package/lib/anydocs/processAnyDocumentStream.js +33 -0
  8. package/lib/anydocs/processAnyDocumentUrl.js +30 -0
  9. package/lib/bankstatements/deleteBankStatement.js +12 -0
  10. package/lib/bankstatements/getBankStatement.js +24 -0
  11. package/lib/bankstatements/getBankStatements.js +28 -0
  12. package/lib/bankstatements/processBankStatement.js +33 -0
  13. package/lib/bankstatements/processBankStatementBase64.js +31 -0
  14. package/lib/bankstatements/processBankStatementStream.js +31 -0
  15. package/lib/bankstatements/processBankStatementUrl.js +30 -0
  16. package/lib/businesscards/deleteBusinessCard.js +12 -0
  17. package/lib/businesscards/getBusinessCard.js +24 -0
  18. package/lib/businesscards/getBusinessCards.js +28 -0
  19. package/lib/businesscards/processBusinessCard.js +27 -0
  20. package/lib/businesscards/processBusinessCardBase64.js +25 -0
  21. package/lib/businesscards/processBusinessCardStream.js +25 -0
  22. package/lib/businesscards/processBusinessCardUrl.js +24 -0
  23. package/lib/checks/deleteCheck.js +12 -0
  24. package/lib/checks/getCheck.js +24 -0
  25. package/lib/checks/getChecks.js +28 -0
  26. package/lib/checks/processCheck.js +33 -0
  27. package/lib/checks/processCheckBase64.js +31 -0
  28. package/lib/checks/processCheckStream.js +31 -0
  29. package/lib/checks/processCheckUrl.js +30 -0
  30. package/lib/client/client.js +63 -0
  31. package/lib/client/constructor.js +27 -0
  32. package/lib/client/function.js +6 -0
  33. package/lib/client/generateSignature.js +26 -0
  34. package/lib/client/getHeaders.js +21 -0
  35. package/lib/client/getUrl.js +9 -0
  36. package/lib/client/request.js +58 -0
  37. package/lib/documents/deleteDocument.js +12 -0
  38. package/lib/documents/getDocument.js +14 -0
  39. package/lib/documents/getDocuments.js +31 -0
  40. package/lib/documents/processDocument.js +37 -0
  41. package/lib/documents/processDocumentBase64.js +37 -0
  42. package/lib/documents/processDocumentStream.js +33 -0
  43. package/lib/documents/processDocumentUrl.js +41 -0
  44. package/lib/documents/tags/addTag.js +14 -0
  45. package/lib/documents/tags/addTags.js +14 -0
  46. package/lib/documents/tags/deleteTags.js +12 -0
  47. package/lib/documents/tags/replaceTags.js +14 -0
  48. package/lib/documents/updateDocument.js +17 -0
  49. package/lib/types/BillTo.ts +11 -0
  50. package/lib/types/BoundingElement.ts +6 -0
  51. package/lib/types/Client.ts +1058 -0
  52. package/lib/types/LineItem.ts +24 -0
  53. package/lib/types/Payment.ts +8 -0
  54. package/lib/types/ShipTo.ts +7 -0
  55. package/lib/types/Tag.ts +4 -0
  56. package/lib/types/TaxLine.ts +9 -0
  57. package/lib/types/Vendor.ts +15 -0
  58. package/lib/types/VeryfiDocument.ts +93 -0
  59. package/lib/types/VeryfiExtraArgs.ts +9 -0
  60. package/lib/w2s/deleteW2.js +12 -0
  61. package/lib/w2s/getW2.js +17 -0
  62. package/lib/w2s/getW2s.js +13 -0
  63. package/lib/w2s/processW2.js +28 -0
  64. package/lib/w2s/processW2Base64.js +30 -0
  65. package/lib/w2s/processW2Stream.js +30 -0
  66. package/lib/w2s/processW2Url.js +32 -0
  67. package/lib/w8bene/deleteW8BENE.js +12 -0
  68. package/lib/w8bene/getW8BENE.js +24 -0
  69. package/lib/w8bene/getW8BENEs.js +28 -0
  70. package/lib/w8bene/processW8BENE.js +33 -0
  71. package/lib/w8bene/processW8BENEBase64.js +31 -0
  72. package/lib/w8bene/processW8BENEStream.js +31 -0
  73. package/lib/w8bene/processW8BENEUrl.js +30 -0
  74. package/lib/w9s/deleteW9.js +12 -0
  75. package/lib/w9s/getW9.js +24 -0
  76. package/lib/w9s/getW9s.js +28 -0
  77. package/lib/w9s/processW9.js +30 -0
  78. package/lib/w9s/processW9Base64.js +31 -0
  79. package/lib/w9s/processW9Stream.js +31 -0
  80. package/lib/w9s/processW9Url.js +27 -0
  81. package/package.json +4 -4
  82. package/lib/main.js +0 -569
  83. package/lib/types/main.d.ts +0 -413
@@ -1,413 +0,0 @@
1
- import fs from "fs";
2
-
3
- /**
4
- * Additional request parameters type
5
- */
6
- export declare type VeryfiExtraArgs = Record<
7
- string | number | symbol,
8
- string | number | boolean
9
- >;
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
-
18
- /**
19
- * Object of data extracted from the document
20
- */
21
- export declare type VeryfiDocument = {
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;
43
- duplicate_of?: null | number;
44
- exch_rate?: null | number;
45
- external_id?: null | string;
46
- final_balance?: null | number | BoundingElement;
47
- guest_count?: null | number | BoundingElement;
48
- id?: null | number;
49
- img_blur?: null | boolean;
50
- img_file_name?: null | string;
51
- img_thumbnail_url?: null | string;
52
- img_url?: null | string;
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;
62
- line_items?: null | LineItem[];
63
- line_items_with_scores?: null | LineItem[];
64
- notes?: null | string;
65
- ocr_text?: null | string;
66
- order_date?: null | string | BoundingElement;
67
- payment?: null | Payment;
68
- pdf_url?: null | string;
69
- previous_balance?: null | number | BoundingElement;
70
- purchase_order_number?: null | string | BoundingElement;
71
- rounding?: null | number | BoundingElement;
72
- server_name?: null | string | BoundingElement;
73
- service_end_date?: null | string;
74
- service_start_date?: null | string;
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;
83
- tax_lines?: null | TaxLine[];
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;
94
- vat_number?: null | string;
95
- vendor?: null | Vendor;
96
- vendors?: null | BoundingElement[];
97
- vin_number?: null | string | BoundingElement;
98
- warnings?: null | string[];
99
- weights?: null | BoundingElement[];
100
- };
101
-
102
- declare type LineItem = {
103
- date?: null | string | BoundingElement;
104
- description?: null | string | BoundingElement;
105
- discount?: null | number | BoundingElement;
106
- end_date?: null | string | BoundingElement;
107
- hsn?: null | string;
108
- id?: null | number;
109
- order?: null | number;
110
- price?: null | number | BoundingElement;
111
- quantity?: null | number | BoundingElement;
112
- reference?: null | string | BoundingElement;
113
- section?: null | string;
114
- sku?: null | string | BoundingElement;
115
- start_date?: null | string;
116
- tags?: null | null[];
117
- tax?: null | number| BoundingElement;
118
- tax_rate?: null | number;
119
- total?: null | number | BoundingElement;
120
- type?: null | string;
121
- unit_of_measure?: null | string;
122
- };
123
-
124
- declare type TaxLine = {
125
- base?: null | number | BoundingElement;
126
- name?: null | string | BoundingElement;
127
- order?: null | number;
128
- rate?: null | number | BoundingElement;
129
- total?: null | number | BoundingElement;
130
- };
131
-
132
- declare type Vendor = {
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;
139
- raw_name?: null | string;
140
- vendor_logo?: null | string | BoundingElement;
141
- vendor_reg_number?: null | string | BoundingElement;
142
- vendor_type?: null | string;
143
- web?: null | string | BoundingElement;
144
- };
145
-
146
- declare type Payment = {
147
- card_number?: null | string | BoundingElement;
148
- display_name?: null | string | BoundingElement;
149
- terms?: null | number | BoundingElement;
150
- type?: null | string;
151
- };
152
-
153
- declare type Tag = {
154
- id?: null | number;
155
- name?: null | string;
156
- };
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
-
174
- export declare class Client {
175
- /**
176
- * Create instance of a Client
177
- * @class
178
- * @param {string} client_id Your Veryfi client id
179
- * @param {string | undefined} client_secret Your Veryfi client secret
180
- * @param {string} username Your Veryfi username
181
- * @param {string} api_key Your Veryfi API key
182
- * @param {string} base_url
183
- * @param {string} api_version
184
- * @param {number} timeout
185
- */
186
- constructor(
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
194
- );
195
-
196
- client_id: string;
197
-
198
- client_secret: string | undefined;
199
-
200
- username: string;
201
-
202
- api_key: string;
203
-
204
- base_url: string;
205
-
206
- api_version: string;
207
-
208
- CATEGORIES: string[];
209
-
210
- private _get_headers;
211
-
212
- private _get_url;
213
-
214
- private _generate_signature;
215
-
216
- private _request;
217
-
218
- /**
219
- * Get all documents
220
- * @memberof Client
221
- * @returns {Promise<VeryfiDocument>} Object of previously processed documents
222
- */
223
- public get_documents(): Promise<VeryfiDocument[]>;
224
-
225
- /**
226
- * Retrieve document by ID
227
- * @memberof Client
228
- * @param {string} document_id ID of the document you'd like to retrieve
229
- * @returns {Promise<VeryfiDocument>} Object of data extracted from the document
230
- */
231
- public get_document(document_id: string): Promise<VeryfiDocument>;
232
-
233
- /**
234
- * Process a document and extract all the fields from it
235
- * @example
236
- * veryfi_client.process_document_buffer('buffer',
237
- * 'receipt.png',
238
- * ['Entertainment','Food'],
239
- * true,
240
- * {'extra': 'parameters'})
241
- *
242
- * @memberof Client
243
- * @param {ReadStream} file ReadStream of a file to submit for data extraction
244
- * @param {String} file_name The file name including the extension
245
- * @param {Array} categories List of categories Veryfi can use to categorize the document
246
- * @param {Boolean} delete_after_processing Delete this document from Veryfi after data has been extracted
247
- * @param {Object} kwargs Additional request parameters
248
- * @returns {JSON} Data extracted from the document
249
- */
250
- public process_document_stream(
251
- file: fs.ReadStream,
252
- file_name: string,
253
- categories?: string[],
254
- delete_after_processing?: boolean,
255
- { ...kwargs }?: VeryfiExtraArgs
256
- ): Promise<VeryfiDocument>;
257
-
258
- /**
259
- * Process a document and extract all the fields from it
260
- * @example
261
- * veryfi_client.process_document_buffer_string('base64_encoded_string',
262
- * 'receipt.png',
263
- * ['Entertainment','Food'],
264
- * true,
265
- * {'extra': 'parameters'})
266
- *
267
- * @memberof Client
268
- * @param {String} base64_encoded_string Buffer string of a file to submit for data extraction
269
- * @param {String} file_name The file name including the extension
270
- * @param {Array} categories List of categories Veryfi can use to categorize the document
271
- * @param {Boolean} delete_after_processing Delete this document from Veryfi after data has been extracted
272
- * @param {Object} kwargs Additional request parameters
273
- * @returns {JSON} Data extracted from the document
274
- */
275
- public process_document_base64string(
276
- base64_encoded_string: string,
277
- file_name: string,
278
- categories?: string[],
279
- delete_after_processing?: boolean,
280
- { ...kwargs }?: VeryfiExtraArgs
281
- ): Promise<VeryfiDocument>;
282
-
283
- /**
284
- * Process a document and extract all the fields from it
285
- * @example
286
- * veryfi_client.process_document(
287
- * 'file/path',
288
- * ['Entertainment', 'Food'],
289
- * true,
290
- * { extra: 'parameters' }
291
- * )
292
- * @memberof Client
293
- * @param {string} file_path Path on disk to a file to submit for data extraction
294
- * @param {string[]} categories List of categories Veryfi can use to categorize the document
295
- * @param {boolean} delete_after_processing Delete this document from Veryfi after data has been extracted
296
- * @param {VeryfiExtraArgs} kwargs Additional request parameters
297
- * @returns {Promise<VeryfiDocument>} Object of data extracted from the document
298
- */
299
- public process_document(
300
- file_path: string,
301
- categories?: string[],
302
- delete_after_processing?: boolean,
303
- { ...kwargs }?: VeryfiExtraArgs
304
- ): Promise<VeryfiDocument>;
305
-
306
- /**
307
- * Process document from url and extract all the fields from it.
308
- * @memberof Client
309
- * @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'.
310
- * @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']
311
- * @param {string[]} categories List of categories to use when categorizing the document
312
- * @param {boolean} delete_after_processing Delete this document from Veryfi after data has been extracted
313
- * @param {number} boost_mode Flag that tells Veryfi whether boost mode should be enabled. When set to 1, Veryfi will skip data enrichment steps, but will process the document faster. Default value for this flag is 0
314
- * @param {string} external_id Optional custom document identifier. Use this if you would like to assign your own ID to documents
315
- * @param {number} max_pages_to_process When sending a long document to Veryfi for processing, this parameter controls how many pages of the document will be read and processed, starting from page 1.
316
- * @param {VeryfiExtraArgs} kwargs Additional request parameters
317
- * @return {Promise<VeryfiDocument>} Object of data extracted from the document
318
- */
319
- public process_document_url(
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
328
- ): Promise<VeryfiDocument>;
329
-
330
- /**
331
- * Delete document from Veryfi
332
- * @memberof Client
333
- * @param {string} document_id ID of the document you'd like to delete
334
- * @returns {Promise<VeryfiDocument>} Object of data extracted from the document
335
- */
336
- public delete_document(document_id: string): Promise<any>;
337
-
338
- /**
339
- * Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` etc.
340
- * @example
341
- * veryfi_client.update_document(
342
- * id,
343
- * { date: '2021-01-01', notes: 'look what I did' }
344
- * )
345
- * @memberof Client
346
- * @param {string} document_id ID of the document you'd like to update
347
- * @param {VeryfiExtraArgs} kwargs fields to update
348
- * @return {Promise<VeryfiDocument>} Object of data extracted from the document with updated fields, if fields are writable. Otherwise, a document with unchanged fields.
349
- */
350
- public update_document(
351
- document_id: string,
352
- { ...kwargs }?: VeryfiExtraArgs
353
- ): Promise<VeryfiDocument>;
354
-
355
- /**
356
- * Add a new tag on an existing document
357
- *
358
- * @param {number} document_id ID of the document you'd like to add a Tag
359
- * @param {string} tag name to add
360
- * @return {Promise<Tag>} response about tag added.
361
- */
362
- public add_tag(document_id: string, tag: string): Promise<Tag>;
363
-
364
- /**
365
- * Delete all tags on an existing document
366
- *
367
- * @param {number} document_id ID of the document you'd like to delete all Tags
368
- * @return {Promise<any>} response about deleted tags.
369
- */
370
- public delete_tags(document_id: string): Promise<any>;
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
-
390
- }
391
-
392
- /**
393
- * Create instance of a Client
394
- * @class
395
- * @param {string} client_id Your Veryfi client id
396
- * @param {string | undefined} client_secret Your Veryfi client secret
397
- * @param {string} username Your Veryfi username
398
- * @param {string} api_key Your Veryfi API key
399
- * @param {string} base_url
400
- * @param {string} api_version
401
- * @param {number} timeout
402
- */
403
- export declare function Client(
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
411
- ): Client;
412
-
413
- export default Client;