@emilgroup/document-uploader
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

Document Uploader

This is a Node.js module that provides functionality for uploading documents to an insurance service. It uses the DocumentUploader class to handle authentication and document uploading.

Installation

Installation To use this module, you need to have Node.js installed on your machine. Once you have that set up, you can install the module using npm:

npm install @emilgroup/document-uploader

Usage

To use the DocumentUploader class, you need to create a new instance with your login credentials and the environment you want to use (Environment.Test for testing or Environment.Production for production):

const uploader = new DocumentUploader('email@emil.de', 'password', Environment.Test);

You also need to provide a file to upload. This example uses the fs module to read the file and get its size:

const file = fs.createReadStream('test.pdf');
const size = fs.statSync('test.pdf').size;

Finally, you can upload the document by calling the uploadDocument method:

(async () => {
  const document = await uploader.uploadDocument(
    {
      templateSlug: 'upload',
      entityType: 'Document',
      description: 'Customer document',
      requester: 'insuranceservice',
      filename: 'test.pdf',
    },
    file,
    size,
  );
})();

Expected response: Optionally is possible to pass extra params to the payload, The field productSlug used to upload documents per product, super useful if we have multiple products:

{
  productSlug: 'homeowner',
}

The field entityId used to upload documents that's belong to example (claims, policies, accounts, etc...) entity:

{
   entityId: 20
}

The field policyCode is optional to indicate if the document belongs to a policy:

{
   policyCode: `pol_Dl5TVWMLhjM7B9`
}

This method takes an object with metadata about the document (including a template slug, entity type, description, and filename), the file itself as a readable stream, and the file size.

License

This module is licensed under the MIT License. See the LICENSE file for more information.

Readme

Keywords

Package Sidebar

Install

npm i @emilgroup/document-uploader

Weekly Downloads

0

Version

0.0.9

License

MIT

Unpacked Size

22.5 kB

Total Files

22

Last publish

Collaborators

  • cover42devs