w8bene/processW8BENE.js

  1. const Client = require('../client/constructor');
  2. const path = require('path');
  3. const fs = require('fs');
  4. /**
  5. * Process a W-8BEN-E document. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/
  6. * @example
  7. * veryfi_client.process_w8bene('file_path')
  8. *
  9. * @memberof Client
  10. * @param {String} file_path Path on disk to a file to submit for data extraction
  11. * @param {boolean} bounding_boxes A field used to determine whether to return bounding_box and bounding_region for extracted fields in the Document response.
  12. * @param {boolean} confidence_details A field used to determine whether to return the score and ocr_score fields in the Document response.
  13. * @param {Object} kwargs Additional request parameters
  14. * @returns {JSON} Data extracted from the document
  15. */
  16. Client.prototype.process_w8bene = async function (
  17. file_path,
  18. bounding_boxes = false,
  19. confidence_details = false,
  20. {...kwargs} = {}
  21. ) {
  22. let file = fs.createReadStream(file_path);
  23. let file_name = path.basename(file_path);
  24. return this.process_w8bene_from_stream(
  25. file,
  26. file_name,
  27. bounding_boxes,
  28. confidence_details,
  29. kwargs
  30. );
  31. }