From 32ac80dd315f58b1e847ae38cc8f357817c95bde Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Thu, 31 Oct 2024 16:33:52 -0500 Subject: [PATCH 1/5] Add support to multi-part --- CONTRIBUTORS.md | 11 + README.md | 588 +++++++++++++----- lib/anydocs/processAnyDocument.js | 11 +- lib/anydocs/processAnyDocumentStream.js | 33 + lib/anydocs/processAnyDocumentUrl.js | 4 +- lib/bankstatements/processBankStatement.js | 9 +- .../processBankStatementBase64.js | 4 +- .../processBankStatementStream.js | 31 + lib/bankstatements/processBankStatementUrl.js | 6 +- lib/businesscards/processBusinessCard.js | 9 +- .../processBusinessCardBase64.js | 4 +- .../processBusinessCardStream.js | 25 + lib/businesscards/processBusinessCardUrl.js | 6 +- lib/checks/processCheck.js | 9 +- lib/checks/processCheckBase64.js | 4 +- lib/checks/processCheckStream.js | 31 + lib/checks/processCheckUrl.js | 6 +- lib/client/client.js | 17 +- lib/client/request.js | 10 +- lib/documents/processDocument.js | 21 +- lib/documents/processDocumentBase64.js | 6 +- lib/documents/processDocumentStream.js | 7 +- lib/documents/processDocumentUrl.js | 4 +- lib/types/Client.ts | 167 ++++- lib/w2s/processW2.js | 11 +- ...cessW2fromBase64.js => processW2Base64.js} | 4 +- lib/w2s/processW2Stream.js | 30 + .../{processW2fromUrl.js => processW2Url.js} | 4 +- lib/w8bene/processW8BENE.js | 9 +- ...NEfromBase64.js => processW8BENEBase64.js} | 4 +- lib/w8bene/processW8BENEStream.js | 31 + lib/w8bene/processW8BENEUrl.js | 6 +- lib/w9s/processW9.js | 9 +- ...cessW9fromBase64.js => processW9Base64.js} | 0 lib/w9s/processW9Stream.js | 31 + .../{processW9fromUrl.js => processW9Url.js} | 4 +- mocks/addTag.json | 2 +- test/main.test.js | 25 +- 38 files changed, 914 insertions(+), 279 deletions(-) create mode 100644 CONTRIBUTORS.md create mode 100644 lib/anydocs/processAnyDocumentStream.js create mode 100644 lib/bankstatements/processBankStatementStream.js create mode 100644 lib/businesscards/processBusinessCardStream.js create mode 100644 lib/checks/processCheckStream.js rename lib/w2s/{processW2fromBase64.js => processW2Base64.js} (97%) create mode 100644 lib/w2s/processW2Stream.js rename lib/w2s/{processW2fromUrl.js => processW2Url.js} (94%) rename lib/w8bene/{processW8BENEfromBase64.js => processW8BENEBase64.js} (97%) create mode 100644 lib/w8bene/processW8BENEStream.js rename lib/w9s/{processW9fromBase64.js => processW9Base64.js} (100%) create mode 100644 lib/w9s/processW9Stream.js rename lib/w9s/{processW9fromUrl.js => processW9Url.js} (92%) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..6197cf9 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,11 @@ +# Release process + +GitHub Actions is configured to handle the release and upload to NPM. To initiate a release, simply create a new tag and publish it at https://github.com/veryfi/veryfi-nodejs/releases + +## Versioning + +package.json manages all the package metadata: +* it uses version to track the current version of the package +* it uses main to point to the entry point of the package +* it uses typings to point to the typescript definition file +* it uses scripts to create documentation, run tests, and build the package diff --git a/README.md b/README.md index c6a4aee..08c1431 100644 --- a/README.md +++ b/README.md @@ -78,156 +78,454 @@ let response = veryfi_client.process_document_url(url, external_id=some_id).then ### Response -```js ->>> { - abn_number: '', - account_number: '', - bill_to_address: '2 Court Square\nNew York, NY 12210', - bill_to_name: 'John Smith', - bill_to_vat_number: '', - card_number: '', - cashback: 0, - category: 'Repairs & Maintenance', - created: '2021-06-28 19:20:02', - currency_code: 'USD', - date: '2019-02-11 00:00:00', - delivery_date: '', - discount: 0, - document_reference_number: '', - document_title: '', - document_type: 'invoice', - due_date: '2019-02-26', - duplicate_of: 37055375, - external_id: '', - id: 37187909, - img_file_name: 'receipt.png', - img_thumbnail_url: 'https://scdn.veryfi.com/receipts/thumbnail.png', - img_url: 'https://scdn.veryfi.com/receipts/receipt.png', - insurance: '', - invoice_number: 'US-001', - is_duplicate: 1, - line_items: [ - { - date: '', - description: 'Front and rear brake cables', - discount: 0, - id: 68004313, - order: 0, - price: 100, - quantity: 1, - reference: '', - section: '', - sku: '', - tax: 0, - tax_rate: 0, - total: 100, - type: 'product', - unit_of_measure: '' - }, +```json +{ + "account_number": "test1", + "accounting_entry_type": "debit", + "balance": null, + "barcodes": [ + { + "data": "101785617711518", + "type": "CODE128" + } + ], + "bill_to": { + "address": null, + "email": null, + "name": null, + "parsed_address": null, + "phone_number": null, + "reg_number": null, + "vat_number": null + }, + "cashback": null, + "category": "Supplies", + "created_date": "2024-10-31 14:38:27", + "currency_code": "USD", + "custom_fields": { + "box_number": null, + "dsadasas": "dasdsadas", + "foo": "bar" + }, + "date": "2018-10-17 09:03:00", + "default_category": "Job Supplies", + "delivery_date": null, + "delivery_note_number": null, + "discount": null, + "document_reference_number": null, + "document_title": null, + "document_type": "receipt", + "due_date": null, + "duplicate_of": null, + "exch_rate": 1, + "external_id": null, + "final_balance": null, + "guest_count": null, + "id": 255371329, + "img_blur": false, + "img_file_name": "255371329.png", + "img_thumbnail_url": "https://scdn.veryfi.com/receipts/919ba4778c039560/d9477032-8537-41cf-97dd-56cb1443a576/thumbnail.png?Expires=1730386417&Signature=VNRx8OISmHUsbPk3YAItcUteEAb4GyLxHTplgCxDxGD2NDE05I7XG~92ikhZhz6oTfCPGqLc7l5Zw0PmDD7di07ZCWRqkpB2OSPUU9ZlHbDLnpenGC7QscEaf8mPb8k0UDKXMY7gw8GCCoRS7IirMnN8aIpaKeRvukIKYCJMqEkX9ncf247BcLyYvnOV20gLieIT1~mofcCebUakr3hBSAbThN0vwYNDXSqth-IpNpDAMcm-nU71KlJWFqdRv4~m3NljwhFkXy1eTK3JiV97EfZJ-Nj~MUxBKWhIjBS~~l-Dp218ogv53Ws8llP5r1RiRrdgqIOtx-8xKa21WU8vbQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ", + "img_url": "https://scdn.veryfi.com/receipts/919ba4778c039560/d9477032-8537-41cf-97dd-56cb1443a576/8e9aebdd-d4f6-4fec-97c8-237dc5bd190d.png?Expires=1730386417&Signature=HTydoDEasZLN7C0QTj-flLCqUqruI3ereSbllb2SEDHrxQTXZPqQ99HE87E5OsWzDmtNumGXYs4UFPjSSOOidUy38EbmyOEljp0VFxPwXMMrJtoVGGShIkTHg-desK3r0fx6xy9l~IX16SEtNCQyZLrzkjTRp0xU9kM1kVuBueW6JewxXUfiIlPu~ITwbwr7PtqRG6uHB3X1myrRXBSv-arbTaLvCrBrmIMGz0gaPH5dA~ehhDSIRvxaKTNTWX-MBloNHfhz~v7xYJyFooDwetyxV968JqGlR-Jx6EAillWbnuflfH5R~VRr~CAtbCsz9gM6q2nqVXPhDDRUl~hrkA__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ", + "incoterms": null, + "insurance": null, + "invoice_number": "17717", + "is_approved": false, + "is_blurry": [ + false + ], + "is_document": true, + "is_duplicate": false, + "is_money_in": false, + "is_transaction": false, + "license_plate_number": null, + "line_items": [ + { + "category": "Supplies", + "country_of_origin": null, + "custom_fields": {}, + "date": null, + "description": "SNIP LEFT \nWISS LEFT-CUT SNIPS", + "discount": 4, + "discount_price": null, + "discount_rate": null, + "end_date": null, + "full_description": "SNIP LEFT \nWISS LEFT-CUT SNIPS", + "gross_total": null, + "hsn": null, + "id": 1146544820, + "lot": null, + "manufacturer": null, + "net_total": null, + "normalized_description": null, + "order": 0, + "price": null, + "quantity": 1, + "reference": null, + "section": null, + "sku": "037103136480", + "start_date": null, + "subtotal": null, + "tags": [ + "line_items_total_greater_than_1" + ], + "tax": null, + "tax_code": null, + "tax_rate": null, + "text": "037103136480 SNIP LEFT \t9.97\nWISS LEFT-CUT SNIPS$4.00", + "total": 9.97, + "type": "product", + "unit_of_measure": null, + "upc": null, + "weight": null + }, + { + "category": "Supplies", + "country_of_origin": null, + "custom_fields": {}, + "date": null, + "description": "MILW5PCKBLDG \nMKE 5PK GENERAL PURPOSE BLADES", + "discount": null, + "discount_price": null, + "discount_rate": null, + "end_date": null, + "full_description": "MILW5PCKBLDG \nMKE 5PK GENERAL PURPOSE BLADES", + "gross_total": null, + "hsn": null, + "id": 1146544822, + "lot": null, + "manufacturer": null, + "net_total": null, + "normalized_description": null, + "order": 1, + "price": null, + "quantity": 1, + "reference": null, + "section": null, + "sku": "045242268061", + "start_date": null, + "subtotal": null, + "tags": [ + "line_items_total_greater_than_1" + ], + "tax": null, + "tax_code": null, + "tax_rate": null, + "text": "045242268061 MILW5PCKBLDG \t1.18\nMKE 5PK GENERAL PURPOSE BLADES", + "total": 1.18, + "type": "product", + "unit_of_measure": null, + "upc": null, + "weight": null + }, + { + "category": "Supplies", + "country_of_origin": null, + "custom_fields": {}, + "date": null, + "description": "1LB. SCREW \nEB NEO SELF-DRILLING 12X1", + "discount": null, + "discount_price": null, + "discount_rate": null, + "end_date": null, + "full_description": "1LB. SCREW \nEB NEO SELF-DRILLING 12X1", + "gross_total": null, + "hsn": null, + "id": 1146544824, + "lot": null, + "manufacturer": null, + "net_total": null, + "normalized_description": null, + "order": 2, + "price": null, + "quantity": 1, + "reference": null, + "section": null, + "sku": "038902058966", + "start_date": null, + "subtotal": null, + "tags": [ + "line_items_total_greater_than_1" + ], + "tax": null, + "tax_code": null, + "tax_rate": null, + "text": "038902058966 1LB. SCREW \t10.57\nEB NEO SELF-DRILLING 12X1", + "total": 10.57, + "type": "product", + "unit_of_measure": null, + "upc": null, + "weight": null + }, + { + "category": "Supplies", + "country_of_origin": null, + "custom_fields": {}, + "date": null, + "description": "1LB. SCREW \nEB NEO SELF-DRILLING 12X3/4", + "discount": null, + "discount_price": null, + "discount_rate": null, + "end_date": null, + "full_description": "1LB. SCREW \nEB NEO SELF-DRILLING 12X3/4", + "gross_total": null, + "hsn": null, + "id": 1146544825, + "lot": null, + "manufacturer": null, + "net_total": null, + "normalized_description": null, + "order": 3, + "price": null, + "quantity": 1, + "reference": null, + "section": null, + "sku": "038902058959", + "start_date": null, + "subtotal": null, + "tags": [ + "line_items_total_greater_than_1" + ], + "tax": null, + "tax_code": null, + "tax_rate": null, + "text": "038902058959 1LB. SCREW \t10.57\nEB NEO SELF-DRILLING 12X3/4", + "total": 10.57, + "type": "product", + "unit_of_measure": null, + "upc": null, + "weight": null + } + ], + "meta": { + "device_id": null, + "device_user_uuid": null, + "duplicates": [ + { + "id": 214960758, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/801c6b7b-8d26-459a-ae4a-db58306e34d3/a9c63167-a8e8-4ed2-8fad-7d06cb17beb3.png?Expires=1730386417&Signature=dbq1l7GZCl7K6rXaiSVMUsoDez6OqL9eapnC83AS3YX-o0omgmaoXGaN3K4nYd1w45U5FnNvB~Fca3nlEh4OVui4HfIK-IQPrc-SED8RHVnfCIM74cD5rDw0lokgT-SAkj5JAVohkHC0WHl-vfXWz-PoYRD6PPs-vkSTnvRdsRMPJRjU2-d9EPj6Rqx1sAm9JEMjIOllHCmpNyeuNaRcBTrPDmv5Z7KpiA4ZbDaEmtpDBJiC4CGsPf4ZgBc9zQy4a~J2Zj54TZPrcU5gVg6WCKibhopCVzw2nuW0TmaHZaxFGmK~W642VzMp3oCBZ1izwfUAJvcPx4WN7fzsp~Txlw__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214966753, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/ceeb34fd-f810-4319-9fd4-b8b1293ad5fb/ef5987c8-e27b-45cb-b009-a12070a68651.png?Expires=1730386417&Signature=OKiIfd6gWDTAjcgIpvSxmk-0KdsZxnEqTwy3Vb85VuZEIkyG31O4ueQy-IwwsTsxa~unKoK4A-N0XEy8dWSvycUwsHZIshyUYyn2sIDqaPdeKQoOAAf3qpAGTFATPujAqnpo0dws0CyDMdpzt0E~D9~tKzFx1W6isq0~eTXEG-~2GTaKG~bEniEgv~xbwJfVINC5O86HDq-bjNjl6Zx~pWlal~LKoANF1SiyRQGHLw4SaE85kTE5FeTUds4b7OyKPqavqa34hGaNWQt0WoPStcfhhXMzaMxX5uefA5eMlMjcW7Iz2jrnU1L1QjTLDHeZ9w3rCHQwlCZuEmG3IJ8R0g__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214966696, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/47446fc9-9ace-411c-8cac-8d8a7378d058/d0de825f-6ed7-4723-92c4-9d48237eba24.png?Expires=1730386417&Signature=GdhaDVHWsiBJi3YUyWonDYfVsUe6uTiXdx0V1CBXRayLPdMqfCVGpPYmlFlsZjBFhvNAS-~D7rHwoZINKa~TIBBYfnZemwjaXmdn~R~ybEic1DbQD~3fU3DecpSEDt76iZRDK~HFefF5BXPHXVhoYqstU7hJFZ~qYR2jpN5hynoMFn6~jY4~0L81msre2lPN3X71yD7ibcdcRbnGCnpT-7sNTrNZ-7CEv9oV1uAbhu54No~B-2XHb6jTgi2q1PM9CkwRJu9dvRtOp~asYQr7gN5EvFpn0yCeUj4Lhv64mwpKYhogFVpHkNAzFSYcplDd522-qbY39cjDNi1F4E4Taw__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214971025, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/76d57a9c-2eb7-49dd-b406-eb55a8ac7b7c/693dc46a-89c9-4dff-a7ea-a3d17e18f0a2.png?Expires=1730386417&Signature=I-d8it0jM0EotcxPiltR9JvOYLWhcdflj5yGzQdw5zWrN2s95~wN8mrczHLYGUHvirEljD4tJew1Ob43DcMLEnl~6Mx-nLYAsDAKWAwN5GDzoBjCD1ddQwnr~irhVymdesnSNc50wIDT9GcpMfgpUfndHK~BslgLBRTz3UgQZQfxHhCveJq5J1oAZZnW-7hPcfvW92C8-M9d6yjwsw7SoN~gGFu7qs8cgQXWS2K0ZjiyaG3RqJhKnVF57JXtM966-J7F3z4woED~dTy-ZAOFdG-Vdg0cCri11183wpU5MJNCfrh-obMvVJA1XzqyjaFM6hB1ruTriBz-k7FmXsvsbg__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214971108, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/4bffa87e-a2e4-480f-86c7-b1267a9bfb9e/1c057703-a1b2-4f7f-b809-16ba79a9635c.png?Expires=1730386417&Signature=Qhv0ZOl5p~AC7n3A0yIhDofWZhR3OHpQl2k2Fzl9DAqaJ6oc8KjCkOr86HNQT2cdOj6ZPF4lR1Wiy~jjY1keExdoOpAGAef2FFUCt8~R6UWFCKY7mZZD8ETqgMMzkMhvVvFsR~Y3tJ8l7NALp~-1YuYghmT~nycJMj0V37s~f0rPc9ft-YbmoIsnwRkSyLWIf6YDOHEbRmrNqvW0VdektyNWPJgreaWENu9ZmZyawCVXcExU~zBsHJx0ySeIqMx7fzVkxeXghTKPgKjOIcCKuqlGAAx0f0jRJ4z8BV8T1n~l0MOezvAL3j3NudWilDkgz8eDWA458GXOgmbxlX-Klw__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214971072, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/135de1f0-b2bb-4a9d-a4ac-2c70c22eb0d9/fd301613-7850-4b0c-b491-5e6f0113a9e6.png?Expires=1730386417&Signature=VD6teyIDHsCXFzgwXsyJrTf506tIqxCAXd1XPnKzpTUhTVoO-lOLh-I9ieucFG4RaL0GeebnOqhiZ1D7nPAiY2h1b2H33rKPp0jRWx0aw7m4L4Vh0-b01URvIJ~D-cnW~iv8CpFGB1AO4voydNqNoMyJSzzdCb1VRbpKpsUkzIhn8n01XkVm7z-98tnSobzh97YLM7-zjDdcNi9bm09Y2HmlepEzl4jHUwIUi-OkG9l12EMj8mWDR2hU5WkL1iIEe8qe6pZkBn4saLyDqE1C42q8ojeaVrV5rDdWpZ7b-QYwkrhmO0Epz6-6ueDKdt6rCBys5m~nWj8-uxNB33SgQA__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214963213, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/ec3b5f22-0d69-49d1-af88-29930edbd19b/2efe3e17-0740-40a5-bd8e-9bb1a96e5718.png?Expires=1730386417&Signature=NdBSHpukLcy2WSvMCnAcAQ-4tkblzeWn~0dmMAukIwm7h~hEz4-01FeglTNU4SmIcylx5X4I8ptydn5rHAIYRHVndHjmpS08dien56sd0JDR3bEgOEqbVfdvfw8K-ibOjEE-00Vbor0NqrhQIfZJX7uSxHU4Ugv-mPRa2TGojTUWCNRPkbNMwj-wqeO3AbTnuTr7sA3tVHkWatFMA1g2WrUH0-HMulRXNCFNuSDhuPc-t4FVdJ2e6SElyUxIYhMzeuSzsK0G0B~qk0KYeEv7dkDwMfl6FLmiV0YOwG40KyKNLkjy1HnUJS7WWuxbU4wzjPjICQK6lw7-Z8MO7IsMew__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214969026, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/a59dcd7d-43be-4ad8-a713-6b496b1ae6fb/491d164e-9002-45b3-9913-890af8b9a3a1.png?Expires=1730386417&Signature=F7l1Altw3P9gCO2C~1yiP-bHAjDd5n4aMYozvIBP55sRC5GF~IgHGMs7~rG6ux~uNjOTFwvT8o-iMhz9S6NSXH5R2YtReqVV0-RyBqQWN2sTbwn0VF-ytXiVGBnh2AxHRKBPc7QCxtsdFYS8~NNFDyVcPPFsr0aJL78Yrr7Gbq4e~~ld2ZvkyUo0t31dmMXj8YkquXNqsQ7xyow31rXukvE1PKC7aOn31h4SCbUauVnniHs0iysIYyCrgdf5FYTApdDINTkHANXHYZxXdSXJX6mpTp5ZZ~j-uTDmGSzq9kBdHQxivoHVt~iW4mS8rigBbUc~KNhXyW2SofvSzA2Vyg__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214973908, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/d26a7012-126e-4f88-8fad-df3914d3b609/65a98087-04c9-4685-bc30-26e4244a84ea.png?Expires=1730386417&Signature=P8LGG2ZuD3rl6U6RCRmuogoV9lhoF4J54lqTMEwUhKhyLQSKyHj81SWQFqQpTV5TiFlwbuAHWzGN-EXCXmy4fkvte9srQcNBkA6iLk6yDsi4-m26lxdhDYgoV0lGJn0UArmfSUgOOGak0OTZFOB0HOntyOZN9RpdvcBwEvZRuqZ8tML8X2EKQAnxklrtdxiZhlzayNSc4zgoYflQpTBU7XJX~XvTCj2~2shhwwQapqG901L1qn2e3ZcS0TU6t9iw9CZWxcHRh~swEGXBR-N7PXtWPrJletoovUFtNYczki2oiXBQCvoX7afQ3J~F8IdJcrN6OrX1WFRJfqxJhD-UlA__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + }, + { + "id": 214973989, + "score": 1, + "url": "https://scdn.veryfi.com/receipts/919ba4778c039560/d6684aac-f493-4094-9f15-ec9fe105aa71/b3c2a9d9-e1e8-457f-a05d-277136bfedc0.png?Expires=1730386417&Signature=NMAkp1yzYH2oFlH7Pie5yQeJUzb1-9pu7RG6ljBzD2Xela9Jbdax1Gn1~fBrWB3xulUFueejXxMyuUvQd0hH08ZrAEpCTLI4Djo4x8-bf5LzKt~wWubp9B~aCuSFOab2rszgmCBRA5OBie8BAletWJYj5GoQZ-Cwp~yKk9rPILZTH6PggsPbNlvsNs0p-v4R7ryK3IQH3AMDRlwmrPzJSQpCsNKufvcB6dmPkju6vJaI05I1vVg4tBooVlssyaoH3UOvlhG435u~sgw6Y4fWG1nsfT~vOjqa~-VtFPD8DBfsEQIzEEFz7ydbewvFDF-tlnef3283sDMxk6~U~hAitQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ" + } + ], + "fraud": { + "attribution": null, + "color": "green", + "custom_types": [], + "decision": "Not Fraud", + "images": [ { - date: '', - description: 'New set of pedal arms', - discount: 0, - id: 68004315, - order: 1, - price: 15, - quantity: 2, - reference: '', - section: '', - sku: '', - tax: 0, - tax_rate: 0, - total: 30, - type: 'product', - unit_of_measure: '' - }, + "is_lcd": false, + "score": 0.95 + } + ], + "pages": [ { - date: '', - description: 'Labor 3hrs', - discount: 0, - id: 68004316, - order: 2, - price: 5, - quantity: 3, - reference: '', - section: '', - sku: '', - tax: 0, - tax_rate: 0, - total: 15, - type: 'service', - unit_of_measure: '' + "is_lcd": { + "score": 0.95, + "value": false + } } ], - notes: '', - ocr_text: '\n' + - '\fEast Repair Inc.\n' + - '1912 Harvest Lane\n' + - 'New York, NY 12210\n' + - '\n' + - 'BILL TO\t\tSHIP TO\tRECEIPT #\tUS-001\n' + - 'John Smith\t\tJohn Smith\tRECEIPT DATE\t11/02/2019\n' + - '2 Court Square\t3787 Pineview Drive\n' + - '\tP.O.#\t2312/2019\n' + - 'New York, NY 12210\tCambridge, MA 12210\n' + - '\tDUE DATE\t26/02/2019\n' + - 'Receipt Total\t\t\t$154.06\n' + - '\n' + - 'QTY DESCRIPTION\t\t\tUNIT PRICE\tAMOUNT\n' + - '1\tFront and rear brake cables\t\t100.00\t100.00\n' + - '2\tNew set of pedal arms\t\t\t15.00\t30.00\n' + - '3\tLabor 3hrs\t\t\t\t5.00\t15.00\n' + - '\n' + - '\tSubtotal\t145.00\n' + - '\tSales Tax 6.25%\t9.06\n' + - '\n' + - 'TERMS & CONDITIONS\n' + - 'Payment is due within 15 days\n' + - 'Please make checks payable to: East Repair\n' + - '\tJohn Smith\n' + - '\tInc.\n', - order_date: '', - payment_display_name: '', - payment_terms: '15 days', - payment_type: '', - phone_number: '', - purchase_order_number: '2312/2019', - rounding: 0, - service_end_date: '', - service_start_date: '', - ship_date: '', - ship_to_address: '3787 Pineview Drive\nCambridge, MA 12210', - ship_to_name: 'John Smith', - shipping: 0, - store_number: '', - subtotal: 145, - tax: 9.06, - tax_lines: [ { base: 0, name: 'Sales', order: 0, rate: 6.25, total: 9.06 } ], - tip: 0, - total: 154.06, - total_weight: '', - tracking_number: '', - updated: '2021-06-28 19:20:03', - vat_number: '', - vendor: { - address: '1912 Harvest Lane\nNew York, NY 12210', - category: 'Car Repair', - email: '', - fax_number: '', - name: 'East Repair', - phone_number: '', - raw_name: 'East Repair Inc.', - vendor_logo: 'https://cdn.veryfi.com/logos/tmp/560806841.png', - vendor_reg_number: '', - vendor_type: 'Car Repair', - web: '' - }, - vendor_account_number: '', - vendor_bank_name: '', - vendor_bank_number: '', - vendor_bank_swift: '', - vendor_iban: '' + "score": 0.05, + "submissions": {}, + "types": [], + "version": null + }, + "handwritten_fields": [], + "language": [ + "en" + ], + "owner": "devapitest", + "pages": [ + { + "height": 1848, + "is_blurry": { + "score": 0.97, + "value": false + }, + "language": [ + "en" + ], + "screenshot": { + "score": 0.9399999976158142, + "type": null + }, + "width": 1048 + } + ], + "processed_pages": 1, + "source": "api", + "source_documents": [ + { + "height": 1848, + "size_kb": 990, + "width": 1048 + } + ], + "total_pages": 1, + "warnings": [ + { + "message": "Decoded Barcode numbers were not found on the document", + "type": "barcode_code_missing_in_ocr" + } + ] + }, + "model": "2.50.0", + "notes": null, + "ocr_text": "HOME\nTHE\n\tMore saving.\n\tMore doing.\"\n\n2250 SOUTHGATE RD, COLORADO SPRINGS, CO\nBECKY NATION STOREMANAGER 719-471-0054\n1518 00000 17717 10/17/18 09:03 AM\nSELF CHECK OUT\n037103136480 SNIP LEFT \t9.97\nWISS LEFT-CUT SNIPS\nNLP Savings\t$4.00\n045242268061 MILW5PCKBLDG \t1.18\nMKE 5PK GENERAL PURPOSE BLADES\n038902058966 1LB. SCREW \t10.57\nEB NEO SELF-DRILLING 12X1\n038902058959 1LB. SCREW \t10.57\nEB NEO SELF-DRILLING 12X3/4\nSUBTOTAL\t32.29\nSALES TAX\t2.66\nTOTAL\t$34.95\nXXXXXXXXXXXX7373 VISA\n\tUSD$ 34.95\nAUTH CODE 025972/8585391\tTA\nAID A0000003131010\t4341505054414C204F4\nE452050595341\nDEPOT", + "order_date": null, + "payment": { + "card_number": "7373", + "display_name": "Visa ***7373", + "terms": null, + "type": "visa" + }, + "pdf_url": "https://scdn.veryfi.com/receipts/919ba4778c039560/d9477032-8537-41cf-97dd-56cb1443a576/cde38dad-6123-454f-842b-e794b108a880.pdf?Expires=1730386417&Signature=MpQOcHRbhvhiOACw~Hg4T6htbXg3tnRgbn0vmIgVYBzcYY2aYsW~lKjBFchpFQAtB-pk2nhZqfFaQRAZKhWAVTJdV5Kje4fneAP205-ekOK5LdB~CfrxcE-gfX6v3GTAKGijYoyWwW9Vodgxnfr3T6EBJc27v1aE~lwF1wXu0nsCLhqp1vnO1BWbxQHF6lW2Pzc9RRZ5qPOpiGRLhu5WbtilboBgTYy30EjQWT1oNeK2GmsteYsx0ygBvV1l92e-0cPgs5kJZnZ7hGNTWyc83MwnZt9KbWcV2Kz3X0T5q902XxmEQ4zKO5XfuIjY~pKLE-~39NxZdg32lRNOKj38Gg__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ", + "previous_balance": null, + "purchase_order_number": null, + "reference_number": "VCDHD-71329", + "rounding": null, + "server_name": null, + "service_end_date": null, + "service_start_date": null, + "ship_date": null, + "ship_to": { + "address": null, + "name": null, + "parsed_address": null + }, + "shipping": null, + "status": "processed", + "store_number": "1518", + "subtotal": 32.29, + "tags": [ + { + "id": 9018171, + "name": "line_items_total_greater_than_1" + }, + { + "id": 9018172, + "name": "is_document" + }, + { + "id": 9018173, + "name": "total_greater_than_1" + }, + { + "id": 9018396, + "name": "extract_tags" + }, + { + "id": 9277238, + "name": "is_fraud_green" + }, + { + "id": 12926297, + "name": "test_rule_1_failure" } + ], + "tax": 2.66, + "tax_lines": [], + "tip": null, + "total": 34.95, + "total_pages": 1, + "total_quantity": null, + "total_weight": null, + "tracking_number": null, + "tracking_numbers": [ + null + ], + "updated_date": "2024-10-31 14:38:35", + "vending_person": null, + "vending_person_number": null, + "vendor": { + "abn_number": null, + "account_currency": null, + "account_number": null, + "address": "2250 SOUTHGATE RD, COLORADO SPRINGS, CO", + "bank_breakdown": [ + {} + ], + "bank_name": null, + "bank_number": null, + "bank_swift": null, + "biller_code": null, + "category": "Nurseries & Gardening", + "country_code": "US", + "email": null, + "external_id": null, + "external_ids": [], + "fax_number": null, + "iban": null, + "lat": 38.798985, + "lng": -104.819856, + "logo": "https://cdn.veryfi.com/logos/us/051403134.jpg", + "logo_name": "the home depot", + "map_url": "https://www.google.com/maps/search/?api=1&query=Home+Depot+2250+SOUTHGATE+RD,+COLORADO+SPRINGS,+CO", + "name": "Home Depot", + "order_number": null, + "parsed_address": {}, + "phone_number": "719-471-0054", + "raw_address": "2250 SOUTHGATE RD, COLORADO SPRINGS, CO\nBECKY NATION", + "raw_name": "DEPOT", + "reg_number": null, + "type": "Nurseries & Gardening", + "vat_number": "452050595341", + "web": null + }, + "vendors": [ + "Home Depot" + ], + "vin_number": null, + "warnings": [], + "weights": [ + null + ] +} ``` ### Updating a document diff --git a/lib/anydocs/processAnyDocument.js b/lib/anydocs/processAnyDocument.js index 7004b0f..617a63b 100644 --- a/lib/anydocs/processAnyDocument.js +++ b/lib/anydocs/processAnyDocument.js @@ -19,14 +19,13 @@ Client.prototype.process_any_document = async function ( max_pages_to_process = 20, {...kwargs} = {} ) { - let endpoint_name = "/any-documents/"; + + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - - return this.process_any_document_from_base64( + + return this.process_any_document_from_stream( + file, file_name, - base64_encoded_string, template_name, max_pages_to_process, kwargs diff --git a/lib/anydocs/processAnyDocumentStream.js b/lib/anydocs/processAnyDocumentStream.js new file mode 100644 index 0000000..c3ae325 --- /dev/null +++ b/lib/anydocs/processAnyDocumentStream.js @@ -0,0 +1,33 @@ +const Client = require('../client/constructor'); +/** + * Process any document and extract all the fields from it. https://docs.veryfi.com/api/anydocs/process-%E2%88%80-doc/ + * @example + * veryfi_client.process_any_document('file/path','blue_print') + * + * @memberof Client + * @param {ReadStream} file ReadStream of a file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {String} template_name name of the extraction templates. + * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ +Client.prototype.process_any_document_from_stream = async function ( + file, + file_name, + template_name, + max_pages_to_process = 20, + {...kwargs} = {} +) { + + let endpoint_name = "/any-documents/"; + let request_arguments = { + "file_name": file_name, + "file": file, + "template_name": template_name, + "max_pages_to_process": max_pages_to_process, + }; + request_arguments = Object.assign(request_arguments, kwargs); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); + return document['data']; +} diff --git a/lib/anydocs/processAnyDocumentUrl.js b/lib/anydocs/processAnyDocumentUrl.js index 8dd3927..1499365 100644 --- a/lib/anydocs/processAnyDocumentUrl.js +++ b/lib/anydocs/processAnyDocumentUrl.js @@ -2,7 +2,7 @@ const Client = require('../client/constructor'); /** * Process any document and extract all the fields from it. https://docs.veryfi.com/api/anydocs/process-%E2%88%80-doc/ * @example - * veryfi_client.process_any_document_url('file_url','blue_print') + * veryfi_client.process_any_document_from_url('file_url','blue_print') * * @memberof Client * @param {String} file_url url file to submit for data extraction @@ -11,7 +11,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_any_document_url = async function ( +Client.prototype.process_any_document_from_url = async function ( file_url, template_name, max_pages_to_process = 20, diff --git a/lib/bankstatements/processBankStatement.js b/lib/bankstatements/processBankStatement.js index b904fc2..223c4c2 100644 --- a/lib/bankstatements/processBankStatement.js +++ b/lib/bankstatements/processBankStatement.js @@ -20,13 +20,12 @@ Client.prototype.process_bank_statement = async function ( {...kwargs} = {} ) { + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - - return this.process_bank_statement_from_base64( + + return this.process_bank_statement_from_stream( + file, file_name, - base64_encoded_string, bounding_boxes, confidence_details, kwargs diff --git a/lib/bankstatements/processBankStatementBase64.js b/lib/bankstatements/processBankStatementBase64.js index 8f038d7..1351439 100644 --- a/lib/bankstatements/processBankStatementBase64.js +++ b/lib/bankstatements/processBankStatementBase64.js @@ -17,7 +17,7 @@ Client.prototype.process_bank_statement_from_base64 = async function ( confidence_details = false, {...kwargs} = {} ) { - + let endpoint_name = "/bank-statements/"; let request_arguments = { "file_name": file_name, @@ -26,6 +26,6 @@ Client.prototype.process_bank_statement_from_base64 = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/bankstatements/processBankStatementStream.js b/lib/bankstatements/processBankStatementStream.js new file mode 100644 index 0000000..b0ed38c --- /dev/null +++ b/lib/bankstatements/processBankStatementStream.js @@ -0,0 +1,31 @@ +const Client = require('../client/constructor'); +/** + * Process bank statement and extract all the fields from it. https://docs.veryfi.com/api/bank-statements/process-a-bank-statement/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ +Client.prototype.process_bank_statement_from_stream = async function ( + file, + file_name, + bounding_boxes = false, + confidence_details = false, + {...kwargs} = {} +) { + + let endpoint_name = "/bank-statements/"; + let request_arguments = { + "file": file, + "file_name": file_name, + "bounding_boxes": bounding_boxes, + "confidence_details": confidence_details, + }; + request_arguments = Object.assign(request_arguments, kwargs); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); + return document['data']; +} diff --git a/lib/bankstatements/processBankStatementUrl.js b/lib/bankstatements/processBankStatementUrl.js index 6b39188..5bd8295 100644 --- a/lib/bankstatements/processBankStatementUrl.js +++ b/lib/bankstatements/processBankStatementUrl.js @@ -2,7 +2,7 @@ const Client = require('../client/constructor'); /** * Process bank statement and extract all the fields from it. https://docs.veryfi.com/api/bank-statements/process-a-bank-statement/ * @example - * veryfi_client.process_bank_statement_url('file_url') + * veryfi_client.process_bank_statement_from_url('file_url') * * @memberof Client * @param {String} file_url url file to submit for data extraction @@ -11,7 +11,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_bank_statement_url = async function ( +Client.prototype.process_bank_statement_from_url = async function ( file_url, bounding_boxes = false, confidence_details = false, @@ -25,6 +25,6 @@ Client.prototype.process_bank_statement_url = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/businesscards/processBusinessCard.js b/lib/businesscards/processBusinessCard.js index f6f36d8..aa38512 100644 --- a/lib/businesscards/processBusinessCard.js +++ b/lib/businesscards/processBusinessCard.js @@ -16,13 +16,12 @@ Client.prototype.process_business_card = async function ( {...kwargs} = {} ) { + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - - return this.process_business_card_from_base64( + + return this.process_business_card_from_stream( + file, file_name, - base64_encoded_string, kwargs ); } diff --git a/lib/businesscards/processBusinessCardBase64.js b/lib/businesscards/processBusinessCardBase64.js index eac8aea..dd0adc5 100644 --- a/lib/businesscards/processBusinessCardBase64.js +++ b/lib/businesscards/processBusinessCardBase64.js @@ -13,13 +13,13 @@ Client.prototype.process_business_card_from_base64 = async function ( file_base64_string, {...kwargs} = {} ) { - + let endpoint_name = "/business-cards/"; let request_arguments = { "file_name": file_name, "file_data": file_base64_string, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/businesscards/processBusinessCardStream.js b/lib/businesscards/processBusinessCardStream.js new file mode 100644 index 0000000..639e80b --- /dev/null +++ b/lib/businesscards/processBusinessCardStream.js @@ -0,0 +1,25 @@ +const Client = require('../client/constructor'); +/** + * Process Business card and extract all the fields from it. https://docs.veryfi.com/api/business-cards/process-a-business-card/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ +Client.prototype.process_business_card_from_stream = async function ( + file, + file_name, + {...kwargs} = {} +) { + + let endpoint_name = "/business-cards/"; + let request_arguments = { + "file": file, + "file_name": file_name, + }; + request_arguments = Object.assign(request_arguments, kwargs); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); + return document['data']; +} diff --git a/lib/businesscards/processBusinessCardUrl.js b/lib/businesscards/processBusinessCardUrl.js index 8c3970e..bb2b104 100644 --- a/lib/businesscards/processBusinessCardUrl.js +++ b/lib/businesscards/processBusinessCardUrl.js @@ -2,14 +2,14 @@ const Client = require('../client/constructor'); /** * Process Check and extract all the fields from it. https://docs.veryfi.com/api/checks/process-a-check/ * @example - * veryfi_client.process_check_url('file_url') + * veryfi_client.process_business_card_from_url('file_url') * * @memberof Client * @param {String} file_url url file to submit for data extraction * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_business_card_url = async function ( +Client.prototype.process_business_card_from_url = async function ( file_url, {...kwargs} = {} ) { @@ -19,6 +19,6 @@ Client.prototype.process_business_card_url = async function ( "file_url": file_url, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/checks/processCheck.js b/lib/checks/processCheck.js index f9be4f0..adbe6e7 100644 --- a/lib/checks/processCheck.js +++ b/lib/checks/processCheck.js @@ -20,13 +20,12 @@ Client.prototype.process_check = async function ( {...kwargs} = {} ) { + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - - return this.process_check_from_base64( + + return this.process_check_from_stream( + file, file_name, - base64_encoded_string, bounding_boxes, confidence_details, kwargs diff --git a/lib/checks/processCheckBase64.js b/lib/checks/processCheckBase64.js index 266e553..5801e98 100644 --- a/lib/checks/processCheckBase64.js +++ b/lib/checks/processCheckBase64.js @@ -17,7 +17,7 @@ Client.prototype.process_check_from_base64 = async function ( confidence_details = false, {...kwargs} = {} ) { - + let endpoint_name = "/checks/"; let request_arguments = { "file_name": file_name, @@ -26,6 +26,6 @@ Client.prototype.process_check_from_base64 = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/checks/processCheckStream.js b/lib/checks/processCheckStream.js new file mode 100644 index 0000000..fa8600a --- /dev/null +++ b/lib/checks/processCheckStream.js @@ -0,0 +1,31 @@ +const Client = require('../client/constructor'); +/** + * Process Check and extract all the fields from it. https://docs.veryfi.com/api/bank-statements/process-a-bank-statement/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ +Client.prototype.process_check_from_stream = async function ( + file, + file_name, + bounding_boxes = false, + confidence_details = false, + {...kwargs} = {} +) { + + let endpoint_name = "/checks/"; + let request_arguments = { + "file": file, + "file_name": file_name, + "bounding_boxes": bounding_boxes, + "confidence_details": confidence_details, + }; + request_arguments = Object.assign(request_arguments, kwargs); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); + return document['data']; +} diff --git a/lib/checks/processCheckUrl.js b/lib/checks/processCheckUrl.js index 3d384ce..3961c7c 100644 --- a/lib/checks/processCheckUrl.js +++ b/lib/checks/processCheckUrl.js @@ -2,7 +2,7 @@ const Client = require('../client/constructor'); /** * Process Check and extract all the fields from it. https://docs.veryfi.com/api/checks/process-a-check/ * @example - * veryfi_client.process_check_url('file_url') + * veryfi_client.process_check_from_url('file_url') * * @memberof Client * @param {String} file_url url file to submit for data extraction @@ -11,7 +11,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_check_url = async function ( +Client.prototype.process_check_from_url = async function ( file_url, bounding_boxes = false, confidence_details = false, @@ -25,6 +25,6 @@ Client.prototype.process_check_url = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/client/client.js b/lib/client/client.js index 6a7c430..54eecf3 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -4,24 +4,28 @@ require('../anydocs/getAnyDocument'); require('../anydocs/getAnyDocuments'); require('../anydocs/processAnyDocument'); require('../anydocs/processAnyDocumentBase64'); +require('../anydocs/processAnyDocumentStream'); require('../anydocs/processAnyDocumentUrl'); require('../bankstatements/deleteBankStatement'); require('../bankstatements/getBankStatement'); require('../bankstatements/getBankStatements'); require('../bankstatements/processBankStatement'); require('../bankstatements/processBankStatementBase64'); +require('../bankstatements/processBankStatementStream'); require('../bankstatements/processBankStatementUrl'); require('../businesscards/deleteBusinessCard'); require('../businesscards/getBusinessCard'); require('../businesscards/getBusinessCards'); require('../businesscards/processBusinessCard'); require('../businesscards/processBusinessCardBase64'); +require('../businesscards/processBusinessCardStream'); require('../businesscards/processBusinessCardUrl'); require('../checks/deleteCheck'); require('../checks/getCheck'); require('../checks/getChecks'); require('../checks/processCheck'); require('../checks/processCheckBase64'); +require('../checks/processCheckStream'); require('../checks/processCheckUrl'); require('../documents/deleteDocument'); require('../documents/getDocument'); @@ -39,18 +43,21 @@ require('../w2s/deleteW2'); require('../w2s/getW2'); require('../w2s/getW2s'); require('../w2s/processW2'); -require('../w2s/processW2fromBase64'); -require('../w2s/processW2fromUrl'); +require('../w2s/processW2Base64'); +require('../w2s/processW2Stream'); +require('../w2s/processW2Url'); require('../w8bene/deleteW8BENE'); require('../w8bene/getW8BENE'); require('../w8bene/getW8BENEs'); require('../w8bene/processW8BENE'); -require('../w8bene/processW8BENEfromBase64'); +require('../w8bene/processW8BENEBase64'); +require('../w8bene/processW8BENEStream'); require('../w8bene/processW8BENEUrl'); require('../w9s/deleteW9'); require('../w9s/getW9'); require('../w9s/getW9s'); require('../w9s/processW9'); -require('../w9s/processW9fromBase64'); -require('../w9s/processW9fromUrl'); +require('../w9s/processW9Base64'); +require('../w9s/processW9Stream'); +require('../w9s/processW9Url'); module.exports = Client; diff --git a/lib/client/request.js b/lib/client/request.js index ff908f2..fab9cf8 100644 --- a/lib/client/request.js +++ b/lib/client/request.js @@ -28,12 +28,11 @@ Client.prototype._request = async function (http_verb, endpoint_name, request_ar if (has_files) { const formData = new FormData(); - for (const key in request_arguments) { - if (request_arguments.hasOwnProperty(key)) { - const value = request_arguments[key]; - formData.append(key, value); + Object.entries(request_arguments).forEach(([key, value]) => { + if (value != null) { + formData.append(key, key === "file" ? value : value.toString()); } - } + }); headers = Object.assign(headers, formData.getHeaders()); const getLength = promisify(formData.getLength).bind(formData); headers['Content-Length'] = await getLength() @@ -44,6 +43,7 @@ Client.prototype._request = async function (http_verb, endpoint_name, request_ar try { return await axios.request({ method: http_verb, + maxBodyLength: Infinity, url: api_url, headers: headers, data: request_arguments, diff --git a/lib/documents/processDocument.js b/lib/documents/processDocument.js index 475fc77..2251666 100644 --- a/lib/documents/processDocument.js +++ b/lib/documents/processDocument.js @@ -23,18 +23,15 @@ Client.prototype.process_document = async function ( {...kwargs} = {} ) { - let endpoint_name = "/documents/"; + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - let request_arguments = { - "file_name": file_name, - "file_data": base64_encoded_string, - "categories": categories, - "auto_delete": auto_delete, - }; - request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); - return document['data']; + + return this.process_document_from_stream( + file, + file_name, + categories, + auto_delete, + kwargs + ); } module.exports = Client; diff --git a/lib/documents/processDocumentBase64.js b/lib/documents/processDocumentBase64.js index 2ed14bd..086f463 100644 --- a/lib/documents/processDocumentBase64.js +++ b/lib/documents/processDocumentBase64.js @@ -2,7 +2,7 @@ const Client = require('../client/constructor'); /** * Process a document and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/process-a-document/ * @example - * veryfi_client.process_document_base64string('base64_encoded_string', + * veryfi_client.process_document_from_base64('base64_encoded_string', * 'receipt.png', * ['Entertainment','Food'], * true, @@ -16,7 +16,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_document_base64string = async function ( +Client.prototype.process_document_from_base64 = async function ( base64_encoded_string, file_name, categories = null, @@ -32,6 +32,6 @@ Client.prototype.process_document_base64string = async function ( "auto_delete": auto_delete, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/documents/processDocumentStream.js b/lib/documents/processDocumentStream.js index 064494d..fda3c76 100644 --- a/lib/documents/processDocumentStream.js +++ b/lib/documents/processDocumentStream.js @@ -11,12 +11,11 @@ const Client = require('../client/constructor'); * @memberof Client * @param {ReadStream} file ReadStream of a file to submit for data extraction * @param {String} file_name The file name including the extension - * @param {Array} categories List of categories Veryfi can use to categorize the document * @param {Boolean} auto_delete Delete this document from Veryfi after data has been extracted * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_document_stream = async function ( +Client.prototype.process_document_from_stream = async function ( file, file_name, auto_delete = false, @@ -24,11 +23,11 @@ Client.prototype.process_document_stream = async function ( ) { let endpoint_name = "/documents/"; let request_arguments = { - "file_name": file_name, "file": file, + "file_name": file_name, "auto_delete": auto_delete }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments, {}, true); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); return document['data']; } diff --git a/lib/documents/processDocumentUrl.js b/lib/documents/processDocumentUrl.js index 933a50d..e861144 100644 --- a/lib/documents/processDocumentUrl.js +++ b/lib/documents/processDocumentUrl.js @@ -2,7 +2,7 @@ const Client = require('../client/constructor'); /** * Process document from url and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/process-a-document/ * @example - * veryfi_client.process_document_url('https://cdn.example.com/receipt.jpg') + * veryfi_client.process_document_from_url('https://cdn.example.com/receipt.jpg') * * @memberof Client * @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". @@ -15,7 +15,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @return {JSON} Data extracted from the document. */ -Client.prototype.process_document_url = async function ( +Client.prototype.process_document_from_url = async function ( file_url = null, file_urls = null, categories = null, diff --git a/lib/types/Client.ts b/lib/types/Client.ts index 8afa719..8c808de 100644 --- a/lib/types/Client.ts +++ b/lib/types/Client.ts @@ -108,7 +108,7 @@ export declare class Client { /** * Process a document and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/process-a-document/ * @example - * veryfi_client.process_document_buffer_string('base64_encoded_string', + * veryfi_client.process_document_from_base64('base64_encoded_string', * 'receipt.png', * ['Entertainment','Food'], * true, @@ -122,7 +122,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_document_base64string( + public process_document_from_base64( base64_encoded_string: string, file_name: string, categories?: string[], @@ -132,22 +132,16 @@ export declare class Client { /** * Process a document and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/process-a-document/ - * @example - * veryfi_client.process_document_buffer('buffer', - * 'receipt.png', - * ['Entertainment','Food'], - * true, - * {'extra': 'parameters'}) * * @memberof Client - * @param {ReadStream} file ReadStream of a file to submit for data extraction + * @param {fs.ReadStream} file ReadStream of a file to submit for data extraction * @param {String} file_name The file name including the extension * @param {Array} categories List of categories Veryfi can use to categorize the document * @param {Boolean} auto_delete Delete this document from Veryfi after data has been extracted * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_document_stream( + public process_document_from_stream( file: fs.ReadStream, file_name: string, categories?: string[], @@ -168,7 +162,7 @@ export declare class Client { * @param {VeryfiExtraArgs} kwargs Additional request parameters * @return {Promise} Object of data extracted from the document */ - public process_document_url( + public process_document_from_url( file_url?: string, file_urls?: string[], categories?: string[], @@ -255,6 +249,25 @@ export declare class Client { {...kwargs}?: VeryfiExtraArgs ): Promise; + /** + * Process any document and extract all the fields from it. https://docs.veryfi.com/api/anydocs/process-%E2%88%80-doc/ + * + * @memberof Client + * @param {ReadStream} file ReadStream of a file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {String} template_name name of the extraction templates. + * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_any_document_from_stream( + file: fs.ReadStream, + file_name: string, + template_name?: string, + max_pages_to_process?: number, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + /** * Process any document and extract all the fields from it. https://docs.veryfi.com/api/anydocs/process-%E2%88%80-doc/ * @@ -286,7 +299,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_any_document_url( + public process_any_document_from_url( file_url: string, template_name?: string, max_pages_to_process?: number, @@ -351,6 +364,25 @@ export declare class Client { {...kwargs}?: VeryfiExtraArgs ): Promise; + /** + * Process bank statement and extract all the fields from it. https://docs.veryfi.com/api/bank-statements/process-a-bank-statement/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_bank_statement_from_stream( + file: fs.ReadStream, + file_name: string, + bounding_boxes?: boolean, + confidence_details?: boolean, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + /** * Process bank statement and extract all the fields from it. https://docs.veryfi.com/api/bank-statements/process-a-bank-statement/ * @example @@ -384,7 +416,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_bank_statement_url( + public process_bank_statement_from_url( file_url: string, bounding_boxes?: boolean, confidence_details?: boolean, @@ -448,8 +480,21 @@ export declare class Client { /** * Process business card and extract all the fields from it. https://docs.veryfi.com/api/business-cards/process-a-business-card/ - * @example - * veryfi_client.process_business_card_from_base64('file/path') + * + * @memberof Client + * @param {fs.ReadStream} file ReadStream of a file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_business_card_from_stream( + file: fs.ReadStream, + file_name: string, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + + /** + * Process business card and extract all the fields from it. https://docs.veryfi.com/api/business-cards/process-a-business-card/ * * @memberof Client * @param {String} file_name The file name including the extension @@ -473,7 +518,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_business_card_url( + public process_business_card_from_url( file_url: string, {...kwargs}?: VeryfiExtraArgs ): Promise; @@ -540,8 +585,6 @@ export declare class Client { /** * Process check and extract all the fields from it. https://docs.veryfi.com/api/checks/process-a-check/ - * @example - * veryfi_client.process_check_from_base64('file/path') * * @memberof Client * @param {String} file_name The file name including the extension @@ -559,6 +602,25 @@ export declare class Client { {...kwargs}?: VeryfiExtraArgs ): Promise; + /** + * Process check and extract all the fields from it. https://docs.veryfi.com/api/checks/process-a-check/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_check_from_stream( + file: fs.ReadStream, + file_name: string, + bounding_boxes?: boolean, + confidence_details?: boolean, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + /** * Process a check document and extract all the fields from it. https://docs.veryfi.com/api/checks/process-a-check/ * @example @@ -571,7 +633,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_check_url( + public process_check_from_url( file_url: string, bounding_boxes?: boolean, confidence_details?: boolean, @@ -637,6 +699,25 @@ export declare class Client { {...kwargs}?: VeryfiExtraArgs ): Promise; + /** + * Process w2 and extract all the fields from it. https://docs.veryfi.com/api/w2s/process-a-w-2/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} auto_delete Delete this document from Veryfi after data has been extracted + * @param {int} 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. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_w2_from_stream( + file: fs.ReadStream, + file_name: string, + auto_delete?: boolean, + max_pages_to_process?: number, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + /** * Process w2 and extract all the fields from it. https://docs.veryfi.com/api/w2s/process-a-w-2/ * @example @@ -672,7 +753,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JsonObject} Data extracted from the document */ - public process_w2_url( + public process_w2_from_url( file_name: string, file_url: string, file_urls?: string[], @@ -743,8 +824,25 @@ export declare class Client { /** * Process W-8BEN-E and extract all the fields from it. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/ - * @example - * veryfi_client.process_w8bene_from_base64('file/path') + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension. + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_w8bene_from_stream( + file: fs.ReadStream, + file_name: string, + bounding_boxes?: boolean, + confidence_details?: boolean, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + + /** + * Process W-8BEN-E and extract all the fields from it. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/ * * @memberof Client * @param {String} file_name The file name including the extension. @@ -765,7 +863,7 @@ export declare class Client { /** * Process W-8BEN-E document and extract all the fields from it. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/ * @example - * veryfi_client.process_w8bene_url('file_url') + * veryfi_client.process_w8bene_from_url('file_url') * * @memberof Client * @param {String} file_url url file to submit for data extraction @@ -774,7 +872,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_w8bene_url( + public process_w8bene_from_url( file_url: string, bounding_boxes?: boolean, confidence_details?: boolean, @@ -841,6 +939,25 @@ export declare class Client { {...kwargs}?: VeryfiExtraArgs ): Promise; + /** + * Process w9 and extract all the fields from it. https://docs.veryfi.com/api/w9s/process-a-w-9/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension. + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ + public process_w9_from_stream( + file: fs.ReadStream, + file_name: string, + bounding_boxes?: boolean, + confidence_details?: boolean, + {...kwargs}?: VeryfiExtraArgs + ): Promise; + /** * Process w9 and extract all the fields from it. https://docs.veryfi.com/api/w9s/process-a-w-9/ * @example @@ -874,7 +991,7 @@ export declare class Client { * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ - public process_w9_url( + public process_w9_from_url( file_url: string, bounding_boxes?: boolean, confidence_details?: boolean, diff --git a/lib/w2s/processW2.js b/lib/w2s/processW2.js index 8199a37..265084a 100644 --- a/lib/w2s/processW2.js +++ b/lib/w2s/processW2.js @@ -15,13 +15,12 @@ Client.prototype.process_w2 = async function ( max_pages_to_process = 1, {...kwargs} = {} ) { - const file_name = path.basename(file_path) - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}) - const base64_encoded_string = Buffer.from(image_file).toString('utf-8') - - return this.process_w2_from_base64( + let file = fs.createReadStream(file_path); + let file_name = path.basename(file_path); + + return this.process_w2_from_stream( + file, file_name, - base64_encoded_string, auto_delete, max_pages_to_process, kwargs diff --git a/lib/w2s/processW2fromBase64.js b/lib/w2s/processW2Base64.js similarity index 97% rename from lib/w2s/processW2fromBase64.js rename to lib/w2s/processW2Base64.js index d62e72a..6afdef9 100644 --- a/lib/w2s/processW2fromBase64.js +++ b/lib/w2s/processW2Base64.js @@ -16,7 +16,7 @@ Client.prototype.process_w2_from_base64 = async function ( max_pages_to_process = null, {...kwargs} = {} ) { - + let endpoint_name = "/w2s/" let request_arguments = { "file_name": file_name, @@ -25,6 +25,6 @@ Client.prototype.process_w2_from_base64 = async function ( "max_pages_to_process": max_pages_to_process, } request_arguments = Object.assign(request_arguments, kwargs); - let response = await this._request("POST", endpoint_name, request_arguments); + let response = await this._request("POST", endpoint_name, request_arguments, null, false); return response['data']; } diff --git a/lib/w2s/processW2Stream.js b/lib/w2s/processW2Stream.js new file mode 100644 index 0000000..c319446 --- /dev/null +++ b/lib/w2s/processW2Stream.js @@ -0,0 +1,30 @@ +const Client = require('../client/constructor'); +/** + * Upload a w2 document from a buffer. https://docs.veryfi.com/api/w2s/process-a-w-2/ + * @memberOf Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} auto_delete Delete this document from Veryfi after data has been extracted + * @param {int} 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. + * @param {Object} kwargs Additional request parameters + * @return {JSON} Data extracted from the document. + */ +Client.prototype.process_w2_from_stream = async function ( + file, + file_name, + auto_delete = null, + max_pages_to_process = null, + {...kwargs} = {} +) { + + let endpoint_name = "/w2s/" + let request_arguments = { + "file": file, + "file_name": file_name, + "auto_delete": auto_delete, + "max_pages_to_process": max_pages_to_process, + } + request_arguments = Object.assign(request_arguments, kwargs); + let response = await this._request("POST", endpoint_name, request_arguments, null, true); + return response['data']; +} diff --git a/lib/w2s/processW2fromUrl.js b/lib/w2s/processW2Url.js similarity index 94% rename from lib/w2s/processW2fromUrl.js rename to lib/w2s/processW2Url.js index b5e1fc0..ed22e4f 100644 --- a/lib/w2s/processW2fromUrl.js +++ b/lib/w2s/processW2Url.js @@ -10,7 +10,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @return {JSON} Data extracted from the document. */ -Client.prototype.process_w2_url = async function ( +Client.prototype.process_w2_from_url = async function ( file_name, file_url, file_urls = null, @@ -27,6 +27,6 @@ Client.prototype.process_w2_url = async function ( "max_pages_to_process": max_pages_to_process } request_arguments = Object.assign(request_arguments, kwargs); - let response = await this._request("POST", endpoint_name, request_arguments); + let response = await this._request("POST", endpoint_name, request_arguments, null, false); return response['data']; } diff --git a/lib/w8bene/processW8BENE.js b/lib/w8bene/processW8BENE.js index 333592f..709d383 100644 --- a/lib/w8bene/processW8BENE.js +++ b/lib/w8bene/processW8BENE.js @@ -20,13 +20,12 @@ Client.prototype.process_w8bene = async function ( {...kwargs} = {} ) { + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - - return this.process_w8bene_from_base64( + + return this.process_w8bene_from_stream( + file, file_name, - base64_encoded_string, bounding_boxes, confidence_details, kwargs diff --git a/lib/w8bene/processW8BENEfromBase64.js b/lib/w8bene/processW8BENEBase64.js similarity index 97% rename from lib/w8bene/processW8BENEfromBase64.js rename to lib/w8bene/processW8BENEBase64.js index 823766d..3e1acc8 100644 --- a/lib/w8bene/processW8BENEfromBase64.js +++ b/lib/w8bene/processW8BENEBase64.js @@ -17,7 +17,7 @@ Client.prototype.process_w8bene_from_base64 = async function ( confidence_details = false, {...kwargs} = {} ) { - + let endpoint_name = "/w-8ben-e/"; let request_arguments = { "file_name": file_name, @@ -26,6 +26,6 @@ Client.prototype.process_w8bene_from_base64 = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/w8bene/processW8BENEStream.js b/lib/w8bene/processW8BENEStream.js new file mode 100644 index 0000000..00ac1a4 --- /dev/null +++ b/lib/w8bene/processW8BENEStream.js @@ -0,0 +1,31 @@ +const Client = require('../client/constructor'); +/** + * Upload a W-8BEN-E document from a buffer. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/ + * + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ +Client.prototype.process_w8bene_from_stream = async function ( + file, + file_name, + bounding_boxes = false, + confidence_details = false, + {...kwargs} = {} +) { + + let endpoint_name = "/w-8ben-e/"; + let request_arguments = { + "file": file, + "file_name": file_name, + "bounding_boxes": bounding_boxes, + "confidence_details": confidence_details, + }; + request_arguments = Object.assign(request_arguments, kwargs); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); + return document['data']; +} diff --git a/lib/w8bene/processW8BENEUrl.js b/lib/w8bene/processW8BENEUrl.js index b63a2ea..a95ce9f 100644 --- a/lib/w8bene/processW8BENEUrl.js +++ b/lib/w8bene/processW8BENEUrl.js @@ -2,7 +2,7 @@ const Client = require('../client/constructor'); /** * Process W-8BEN-E and extract all the fields from it. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/ * @example - * veryfi_client.process_w8bene_url('file_url') + * veryfi_client.process_w8bene_from_url('file_url') * * @memberof Client * @param {String} file_url url file to submit for data extraction @@ -11,7 +11,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_w8bene_url = async function ( +Client.prototype.process_w8bene_from_url = async function ( file_url, bounding_boxes = false, confidence_details = false, @@ -25,6 +25,6 @@ Client.prototype.process_w8bene_url = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/lib/w9s/processW9.js b/lib/w9s/processW9.js index d3db547..61dfe5e 100644 --- a/lib/w9s/processW9.js +++ b/lib/w9s/processW9.js @@ -17,13 +17,12 @@ Client.prototype.process_w9 = async function ( {...kwargs} = {} ) { + let file = fs.createReadStream(file_path); let file_name = path.basename(file_path); - const image_file = fs.readFileSync(file_path, {encoding: 'base64'}); - const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - - return this.process_w9_from_base64( + + return this.process_w9_from_stream( + file, file_name, - base64_encoded_string, bounding_boxes, confidence_details, kwargs diff --git a/lib/w9s/processW9fromBase64.js b/lib/w9s/processW9Base64.js similarity index 100% rename from lib/w9s/processW9fromBase64.js rename to lib/w9s/processW9Base64.js diff --git a/lib/w9s/processW9Stream.js b/lib/w9s/processW9Stream.js new file mode 100644 index 0000000..7b59b8a --- /dev/null +++ b/lib/w9s/processW9Stream.js @@ -0,0 +1,31 @@ +const Client = require('../client/constructor'); +/** + * Upload a w9 document from a buffer. https://docs.veryfi.com/api/w9s/process-a-w-9/ + * @memberof Client + * @param {fs.ReadStream} file file to submit for data extraction + * @param {String} file_name The file name including the extension + * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response. + * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} Data extracted from the document + */ +Client.prototype.process_w9_from_stream = async function ( + file, + file_name, + bounding_boxes = false, + confidence_details = false, + {...kwargs} = {} +) { + + let endpoint_name = "/w9s/"; + let request_arguments = { + "file": file, + "file_name": file_name, + "bounding_boxes": bounding_boxes, + "confidence_details": confidence_details, + }; + request_arguments = Object.assign(request_arguments, kwargs); + let document = await this._request("POST", endpoint_name, request_arguments, null, true); + return document['data']; +} + diff --git a/lib/w9s/processW9fromUrl.js b/lib/w9s/processW9Url.js similarity index 92% rename from lib/w9s/processW9fromUrl.js rename to lib/w9s/processW9Url.js index b864b1f..af48859 100644 --- a/lib/w9s/processW9fromUrl.js +++ b/lib/w9s/processW9Url.js @@ -8,7 +8,7 @@ const Client = require('../client/constructor'); * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ -Client.prototype.process_w9_url = async function ( +Client.prototype.process_w9_from_url = async function ( file_url, bounding_boxes = false, confidence_details = false, @@ -22,6 +22,6 @@ Client.prototype.process_w9_url = async function ( "confidence_details": confidence_details, }; request_arguments = Object.assign(request_arguments, kwargs); - let document = await this._request("POST", endpoint_name, request_arguments); + let document = await this._request("POST", endpoint_name, request_arguments, null, false); return document['data']; } diff --git a/mocks/addTag.json b/mocks/addTag.json index 9a4e7ec..89c375d 100644 --- a/mocks/addTag.json +++ b/mocks/addTag.json @@ -1,6 +1,6 @@ { "data": { "id": 6673474, - "name": "test_tag" + "name": "TEST_TAG" } } diff --git a/test/main.test.js b/test/main.test.js index 2766022..e472469 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -25,6 +25,7 @@ describe('Processing documents', () => { const mockResponse = require('../mocks/receipt.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } + let response = await veryfi_client.process_document('resources/receipt.png'); expect(response['vendor']['name']).toContain('Home Depot'); } catch (error) { @@ -41,7 +42,7 @@ describe('Processing documents', () => { const file_path = 'resources/receipt.png'; const image_file = fs.readFileSync(file_path, { encoding: 'base64' }); const base64_encoded_string = Buffer.from(image_file).toString('utf-8'); - let response = await veryfi_client.process_document_base64string( + let response = await veryfi_client.process_document_from_base64( base64_encoded_string, 'receipt.png' ); @@ -59,7 +60,7 @@ describe('Processing documents', () => { } const file_path = 'resources/receipt.png'; const file = fs.createReadStream(file_path); - let response = await veryfi_client.process_document_stream( + let response = await veryfi_client.process_document_from_stream( file, 'receipt.png' ); @@ -75,7 +76,7 @@ describe('Processing documents', () => { const mockResponse = require('../mocks/receipt.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_document_url('https://cdn.veryfi.com/receipts/92233902-c94a-491d-a4f9-0d61f9407cd2.pdf'); + let response = await veryfi_client.process_document_from_url('https://cdn.veryfi.com/receipts/92233902-c94a-491d-a4f9-0d61f9407cd2.pdf'); expect(response['vendor']['name']).toBeDefined(); } catch (error) { throw new Error(error); @@ -91,7 +92,7 @@ describe('Processing documents', () => { const settings = { bounding_boxes: true }; - let response = await veryfi_client.process_document('resources/receipt.png', null, null, settings); + let response = await veryfi_client.process_document('resources/receipt.png', null, false, settings); expect(response).toBeDefined() } catch (error) { throw new Error(error); @@ -149,7 +150,7 @@ describe('Managing tags', () => { const mockResponse = require('../mocks/addTag.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let tag_name = 'test_tag' + let tag_name = 'TEST_TAG' const doc_id = 252469322; let tag = await veryfi_client.add_tag(doc_id, tag_name); expect(tag.name).toBe(tag_name) @@ -293,7 +294,7 @@ describe('Processing any documents', () => { const mockResponse = require('../mocks/processAnyDocument.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_any_document_url('https://cdn-dev.veryfi.com/testing/veryfi-python/driver_license.png', 'us_driver_license'); + let response = await veryfi_client.process_any_document_from_url('https://cdn-dev.veryfi.com/testing/veryfi-python/driver_license.png', 'us_driver_license'); expect(response).toBeDefined(); } catch (error) { throw new Error(error); @@ -362,7 +363,7 @@ describe('Processing business cards', () => { const mockResponse = require('../mocks/processBusinesscard.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_business_card_url('https://cdn-dev.veryfi.com/testing/veryfi-python/business_card.jpg'); + let response = await veryfi_client.process_business_card_from_url('https://cdn-dev.veryfi.com/testing/veryfi-python/business_card.jpg'); expect(response).toBeDefined(); } catch (error) { throw new Error(error); @@ -431,7 +432,7 @@ describe('Processing bank statement', () => { const mockResponse = require('../mocks/processBankStatement.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_bank_statement_url('https://cdn-dev.veryfi.com/testing/veryfi-python/bankstatement.pdf'); + let response = await veryfi_client.process_bank_statement_from_url('https://cdn-dev.veryfi.com/testing/veryfi-python/bankstatement.pdf'); expect(response).toBeDefined(); } catch (error) { throw new Error(error); @@ -500,7 +501,7 @@ describe('Processing checks', () => { const mockResponse = require('../mocks/processCheck.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_check_url('https://cdn-dev.veryfi.com/testing/veryfi-python/check.pdf'); + let response = await veryfi_client.process_check_from_url('https://cdn-dev.veryfi.com/testing/veryfi-python/check.pdf'); expect(response).toBeDefined(); } catch (error) { throw new Error(error); @@ -568,7 +569,7 @@ describe('Process w2 documents', () => { const mockResponse = require('../mocks/processW2.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_w2_url( + let response = await veryfi_client.process_w2_from_url( 'w2.png', 'https://cdn.veryfi.com/wp-content/uploads/image.png', null, @@ -641,7 +642,7 @@ describe('Processing W-8BEN-E', () => { const mockResponse = require('../mocks/processW8bene.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_w8bene_url('https://cdn-dev.veryfi.com/testing/veryfi-python/w8bene.pdf'); + let response = await veryfi_client.process_w8bene_from_url('https://cdn-dev.veryfi.com/testing/veryfi-python/w8bene.pdf'); expect(response).toBeDefined(); } catch (error) { throw new Error(error); @@ -710,7 +711,7 @@ describe('Processing W9s', () => { const mockResponse = require('../mocks/processW9.json'); veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); } - let response = await veryfi_client.process_w9_url('https://cdn-dev.veryfi.com/testing/veryfi-python/w9.pdf'); + let response = await veryfi_client.process_w9_from_url('https://cdn-dev.veryfi.com/testing/veryfi-python/w9.pdf'); expect(response).toBeDefined(); } catch (error) { throw new Error(error); From ae002bd30701c1a31890d72fdb3b43e5483e17fc Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Fri, 1 Nov 2024 09:22:06 -0500 Subject: [PATCH 2/5] Move from template_name to blueprint_name --- lib/anydocs/processAnyDocumentBase64.js | 8 ++++---- lib/anydocs/processAnyDocumentStream.js | 6 +++--- lib/anydocs/processAnyDocumentUrl.js | 6 +++--- lib/types/Client.ts | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/anydocs/processAnyDocumentBase64.js b/lib/anydocs/processAnyDocumentBase64.js index c31c88e..99a58df 100644 --- a/lib/anydocs/processAnyDocumentBase64.js +++ b/lib/anydocs/processAnyDocumentBase64.js @@ -5,7 +5,7 @@ const Client = require('../client/constructor'); * @memberof Client * @param {String} file_name The file name including the extension * @param {String} file_base64_string To submit a file for data extraction, encode the file in Base64 format and ensure it includes the MIME type. The Base64 string should follow this structure: data:${mimeType};base64,${base64String} - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -13,16 +13,16 @@ const Client = require('../client/constructor'); Client.prototype.process_any_document_from_base64 = async function ( file_name, file_base64_string, - template_name, + blueprint_name, max_pages_to_process = 20, {...kwargs} = {} ) { - + let endpoint_name = "/any-documents/"; let request_arguments = { "file_name": file_name, "file_data": file_base64_string, - "template_name": template_name, + "blueprint_name": blueprint_name, "max_pages_to_process": max_pages_to_process, }; request_arguments = Object.assign(request_arguments, kwargs); diff --git a/lib/anydocs/processAnyDocumentStream.js b/lib/anydocs/processAnyDocumentStream.js index c3ae325..eaedfec 100644 --- a/lib/anydocs/processAnyDocumentStream.js +++ b/lib/anydocs/processAnyDocumentStream.js @@ -7,7 +7,7 @@ const Client = require('../client/constructor'); * @memberof Client * @param {ReadStream} file ReadStream of a file to submit for data extraction * @param {String} file_name The file name including the extension - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -15,7 +15,7 @@ const Client = require('../client/constructor'); Client.prototype.process_any_document_from_stream = async function ( file, file_name, - template_name, + blueprint_name, max_pages_to_process = 20, {...kwargs} = {} ) { @@ -24,7 +24,7 @@ Client.prototype.process_any_document_from_stream = async function ( let request_arguments = { "file_name": file_name, "file": file, - "template_name": template_name, + "template_name": blueprint_name, "max_pages_to_process": max_pages_to_process, }; request_arguments = Object.assign(request_arguments, kwargs); diff --git a/lib/anydocs/processAnyDocumentUrl.js b/lib/anydocs/processAnyDocumentUrl.js index 1499365..4e2f188 100644 --- a/lib/anydocs/processAnyDocumentUrl.js +++ b/lib/anydocs/processAnyDocumentUrl.js @@ -6,14 +6,14 @@ const Client = require('../client/constructor'); * * @memberof Client * @param {String} file_url url file to submit for data extraction - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ Client.prototype.process_any_document_from_url = async function ( file_url, - template_name, + blueprint_name, max_pages_to_process = 20, {...kwargs} = {} ) { @@ -21,7 +21,7 @@ Client.prototype.process_any_document_from_url = async function ( let endpoint_name = "/any-documents/"; let request_arguments = { "file_url": file_url, - "template_name": template_name, + "template_name": blueprint_name, "max_pages_to_process": max_pages_to_process, }; request_arguments = Object.assign(request_arguments, kwargs); diff --git a/lib/types/Client.ts b/lib/types/Client.ts index 8c808de..906873a 100644 --- a/lib/types/Client.ts +++ b/lib/types/Client.ts @@ -237,14 +237,14 @@ export declare class Client { * * @memberof Client * @param {String} file_path Path on disk to a file to submit for data extraction - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ public process_any_document( file_path: string, - template_name?: string, + blueprint_name?: string, max_pages_to_process?: number, {...kwargs}?: VeryfiExtraArgs ): Promise; @@ -255,7 +255,7 @@ export declare class Client { * @memberof Client * @param {ReadStream} file ReadStream of a file to submit for data extraction * @param {String} file_name The file name including the extension - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -263,7 +263,7 @@ export declare class Client { public process_any_document_from_stream( file: fs.ReadStream, file_name: string, - template_name?: string, + blueprint_name?: string, max_pages_to_process?: number, {...kwargs}?: VeryfiExtraArgs ): Promise; @@ -274,7 +274,7 @@ export declare class Client { * @memberof Client * @param {String} file_name The file name including the extension * @param {String} file_base64_string To submit a file for data extraction, encode the file in Base64 format and ensure it includes the MIME type. The Base64 string should follow this structure: data:${mimeType};base64,${base64String} - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -282,7 +282,7 @@ export declare class Client { public process_any_document_from_base64( file_name: string, file_base64_string: string, - template_name?: string, + blueprint_name?: string, max_pages_to_process?: number, {...kwargs}?: VeryfiExtraArgs ): Promise; @@ -294,14 +294,14 @@ export declare class Client { * * @memberof Client * @param {String} file_url url file to submit for data extraction - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ public process_any_document_from_url( file_url: string, - template_name?: string, + blueprint_name?: string, max_pages_to_process?: number, {...kwargs}?: VeryfiExtraArgs ): Promise; From 29d0aa3192399f00ccb94c19c4b02c105fdaf230 Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Fri, 1 Nov 2024 09:25:40 -0500 Subject: [PATCH 3/5] Move from template_name to blueprint_name --- lib/anydocs/processAnyDocument.js | 4 ++-- lib/anydocs/processAnyDocumentStream.js | 2 +- lib/anydocs/processAnyDocumentUrl.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/anydocs/processAnyDocument.js b/lib/anydocs/processAnyDocument.js index 617a63b..a000f1e 100644 --- a/lib/anydocs/processAnyDocument.js +++ b/lib/anydocs/processAnyDocument.js @@ -8,14 +8,14 @@ const fs = require('fs'); * * @memberof Client * @param {String} file_path Path on disk to a file to submit for data extraction - * @param {String} template_name name of the extraction templates. + * @param {String} blueprint_name name of the extraction templates. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document */ Client.prototype.process_any_document = async function ( file_path, - template_name, + blueprint_name, max_pages_to_process = 20, {...kwargs} = {} ) { diff --git a/lib/anydocs/processAnyDocumentStream.js b/lib/anydocs/processAnyDocumentStream.js index eaedfec..7d6bebd 100644 --- a/lib/anydocs/processAnyDocumentStream.js +++ b/lib/anydocs/processAnyDocumentStream.js @@ -24,7 +24,7 @@ Client.prototype.process_any_document_from_stream = async function ( let request_arguments = { "file_name": file_name, "file": file, - "template_name": blueprint_name, + "blueprint_name": blueprint_name, "max_pages_to_process": max_pages_to_process, }; request_arguments = Object.assign(request_arguments, kwargs); diff --git a/lib/anydocs/processAnyDocumentUrl.js b/lib/anydocs/processAnyDocumentUrl.js index 4e2f188..3d9dad8 100644 --- a/lib/anydocs/processAnyDocumentUrl.js +++ b/lib/anydocs/processAnyDocumentUrl.js @@ -21,7 +21,7 @@ Client.prototype.process_any_document_from_url = async function ( let endpoint_name = "/any-documents/"; let request_arguments = { "file_url": file_url, - "template_name": blueprint_name, + "blueprint_name": blueprint_name, "max_pages_to_process": max_pages_to_process, }; request_arguments = Object.assign(request_arguments, kwargs); From 9bdb2f9dfbbec245446f0a63f9c22ac260aeb166 Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Fri, 1 Nov 2024 09:33:34 -0500 Subject: [PATCH 4/5] Update processAnyDocument.js --- lib/anydocs/processAnyDocument.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/anydocs/processAnyDocument.js b/lib/anydocs/processAnyDocument.js index a000f1e..64f2bd5 100644 --- a/lib/anydocs/processAnyDocument.js +++ b/lib/anydocs/processAnyDocument.js @@ -26,7 +26,7 @@ Client.prototype.process_any_document = async function ( return this.process_any_document_from_stream( file, file_name, - template_name, + blueprint_name, max_pages_to_process, kwargs ); From 531b2d730ebdb22507594f6cc82cc7a3e456220f Mon Sep 17 00:00:00 2001 From: Alejandro Uribe Date: Fri, 1 Nov 2024 09:36:40 -0500 Subject: [PATCH 5/5] Update docs for blueprints --- lib/anydocs/processAnyDocument.js | 2 +- lib/anydocs/processAnyDocumentBase64.js | 2 +- lib/anydocs/processAnyDocumentStream.js | 2 +- lib/anydocs/processAnyDocumentUrl.js | 2 +- lib/types/Client.ts | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/anydocs/processAnyDocument.js b/lib/anydocs/processAnyDocument.js index 64f2bd5..b1120ff 100644 --- a/lib/anydocs/processAnyDocument.js +++ b/lib/anydocs/processAnyDocument.js @@ -8,7 +8,7 @@ const fs = require('fs'); * * @memberof Client * @param {String} file_path Path on disk to a file to submit for data extraction - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document diff --git a/lib/anydocs/processAnyDocumentBase64.js b/lib/anydocs/processAnyDocumentBase64.js index 99a58df..ec2212c 100644 --- a/lib/anydocs/processAnyDocumentBase64.js +++ b/lib/anydocs/processAnyDocumentBase64.js @@ -5,7 +5,7 @@ const Client = require('../client/constructor'); * @memberof Client * @param {String} file_name The file name including the extension * @param {String} file_base64_string To submit a file for data extraction, encode the file in Base64 format and ensure it includes the MIME type. The Base64 string should follow this structure: data:${mimeType};base64,${base64String} - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document diff --git a/lib/anydocs/processAnyDocumentStream.js b/lib/anydocs/processAnyDocumentStream.js index 7d6bebd..82de124 100644 --- a/lib/anydocs/processAnyDocumentStream.js +++ b/lib/anydocs/processAnyDocumentStream.js @@ -7,7 +7,7 @@ const Client = require('../client/constructor'); * @memberof Client * @param {ReadStream} file ReadStream of a file to submit for data extraction * @param {String} file_name The file name including the extension - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document diff --git a/lib/anydocs/processAnyDocumentUrl.js b/lib/anydocs/processAnyDocumentUrl.js index 3d9dad8..d172122 100644 --- a/lib/anydocs/processAnyDocumentUrl.js +++ b/lib/anydocs/processAnyDocumentUrl.js @@ -6,7 +6,7 @@ const Client = require('../client/constructor'); * * @memberof Client * @param {String} file_url url file to submit for data extraction - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document diff --git a/lib/types/Client.ts b/lib/types/Client.ts index 906873a..e6c56d9 100644 --- a/lib/types/Client.ts +++ b/lib/types/Client.ts @@ -237,7 +237,7 @@ export declare class Client { * * @memberof Client * @param {String} file_path Path on disk to a file to submit for data extraction - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -255,7 +255,7 @@ export declare class Client { * @memberof Client * @param {ReadStream} file ReadStream of a file to submit for data extraction * @param {String} file_name The file name including the extension - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -274,7 +274,7 @@ export declare class Client { * @memberof Client * @param {String} file_name The file name including the extension * @param {String} file_base64_string To submit a file for data extraction, encode the file in Base64 format and ensure it includes the MIME type. The Base64 string should follow this structure: data:${mimeType};base64,${base64String} - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document @@ -294,7 +294,7 @@ export declare class Client { * * @memberof Client * @param {String} file_url url file to submit for data extraction - * @param {String} blueprint_name name of the extraction templates. + * @param {String} blueprint_name The name of the extraction blueprints to use. * @param {number} max_pages_to_process The number of pages to process for the document. The limit is 50 pages per document. * @param {Object} kwargs Additional request parameters * @returns {JSON} Data extracted from the document