0.0.9 • Published 5 months ago

@emilgroup/document-uploader v0.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

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.

0.0.9

5 months ago

0.0.8

7 months ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago