1.1.15 • Published 2 years ago

lazarus-forms v1.1.15

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Lazarus Forms

Lazarus Forms is a Node.js library that was created to ease the use of integrating Lazarus's Forms API to one's applications.

Prerequisites

To be able to make use of this library, you must have an active Lazarus Forms account. To get started, head over to our website.

Installing

Using npm:

npm install lazarus-forms

Using Lazarus Forms in your app

import forms from 'lazarus-forms'

//TODO: Replace the orgId and authKey with your organzation's credentials
forms.init('orgId','authKey')
  .then(response => {
    if (response['state'] === 'Success') {
      //...
    } else {
      //...
    }
  })
  .catch(error => {
    //...
  })

Methods

Upload a file directly, get back a json.

How to call the function:

forms.analyzeFileForJson(sourceType, file)

ParameterRequiredTypeDescription
sourceTypeYesstringUsed to determine how the file is being passed to the function. Currently only supported values are 'path' and 'file'.
fileYesstring/objectIf sourceType is 'path' expects to receive a path string to the file. If the sourceType is 'file', it expects to receive a file object.

Expected response:

If success:

{
  "state": "Success",
  "response": {...} 
}

The response value is the data retrieved from a successful API call as seen in the docs

If there was a failure initializing the API call:

{
  "state": "Error",
  "response": "Reason for error" 
}

If there was a failure making the API call:

{
  "state": "Error",
  "response": "Reason for error" 
  "responseStatus": Int
}

Upload a file via url, get back a json.

forms.analyzeUrlForJson(inputUrl, fileId, metadata, webhook)

ParameterRequiredTypeDescription
inputUrlYesstringUrl to file to extract from: Must be a PDF, JPEG, PNG, or TIFF.
fileIdNostringCustom ID for document. If not present, will default to file name.
metadataNoobjectCustom JSON to be passed as part of the response data.
webhookNostringWebhook to ping after API runs.

Expected response:

If success:

{
  "state": "Success",
  "response": {...} 
}

The response value is the data retrieved from a successful API call as seen in the docs

If there was a failure initializing the API call:

{
  "state": "Error",
  "response": "Reason for error" 
}

If there was a failure making the API call:

{
  "state": "Error",
  "response": "Reason for error" 
  "responseStatus": Int
}

Upload a file directly, get back a zip file.

forms.analyzeFileForZip(sourceType, file)

ParameterRequiredTypeDescription
sourceTypeYesstringUsed to determine how the file is being passed to the function. Currently only supported values are 'path' and 'file'.
fileYesstring/objectIf sourceType is 'path' expects to receive a path string to the file. If the sourceType is 'file', it expects to receive a file object.

Expected response:

If success:

{
  "state": "Success",
  "response": {...} 
}

The response value is the data retrieved from a successful API call as seen in the docs

To save the file if it is being returned client-side: using a package such as file-saver can be used to integrate the process:

import {saveAs} from 'file-saver';

forms.analyzeFileForZip('file', file)
  .then((res) => {
    return res.response.data
  })
  .then((data) => {
    let extension = 'zip';
    let tempFileName = `test`
    let fileName = `${tempFileName}.${extension}`;

    const blob = new Blob([data], {
      type: 'application/octet-stream'
    })

    saveAs(blob, fileName)
  })
  .catch(error => {
    console.log('error', error)
  })

If there was a failure initializing the API call:

{
  "state": "Error",
  "response": "Reason for error" 
}

If there was a failure making the API call:

{
  "state": "Error",
  "response": "Reason for error" 
  "responseStatus": Int
}

Upload a file via url, get back a zip file.

forms.analyzeUrlForZip(inputUrl, fileId, metadata, webhook)

ParameterRequiredTypeDescription
inputUrlYesstringUrl to file to extract from: Must be a PDF, JPEG, PNG, or TIFF.
fileIdNostringCustom ID for document. If not present, will default to file name.
metadataNoobjectCustom JSON to be passed as part of the response data.
webhookNostringWebhook to ping after API runs.

Expected response:

If success:

{
  "state": "Success",
  "response": {...} 
}

The response value is the data retrieved from a successful API call as seen in the docs

To save the file if it is being returned client-side: using a package such as file-saver can be used to integrate the process:

import {saveAs} from 'file-saver';

forms.analyzeFileForZip('file', file)
  .then((res) => {
    return res.response.data
  })
  .then((data) => {
    let extension = 'zip';
    let tempFileName = `test`
    let fileName = `${tempFileName}.${extension}`;

    const blob = new Blob([data], {
      type: 'application/octet-stream'
    })

    saveAs(blob, fileName)
  })
  .catch(error => {
    console.log('error', error)
  })

If there was a failure initializing the API call:

{
  "state": "Error",
  "response": "Reason for error" 
}

If there was a failure making the API call:

{
  "state": "Error",
  "response": "Reason for error" 
  "responseStatus": Int
}

Async queue a url via json, send a zip file to an output url.

forms.queueUrlForZip(inputUrl, outputUrl, outputUrlHeaders, fileId, metadata, webhook)

ParameterRequiredTypeDescription
inputUrlYesstringUrl to file to extract from: Must be a PDF, JPEG, PNG, or TIFF.
outputUrlYesstringUrl where to send output zip file. Must be open to PUT requests.
outputUrlHeadersNoobjectJson with headers to be sent to your outputUrl.
fileIdNostringCustom ID for document. If not present, will default to file name.
metadataNoobjectCustom JSON to be passed as part of the response data.
webhookNostringWebhook to ping after API runs.

Expected response:

If success:

{
  "state": "Success",
  "response": {...} 
}

The response value is the data retrieved from a successful API call as seen in the docs

If there was a failure initializing the API call:

{
  "state": "Error",
  "response": "Reason for error" 
}

If there was a failure making the API call:

{
  "state": "Error",
  "response": "Reason for error" 
  "responseStatus": Int
}

Common Errors

ResponseStatusMeaningDescription
400FAILUREBad Requestbad request and failure to read
401AUTH_FAILUREUnauthorizedunauthorized attempt
403FAILUREForbiddeninvalid subscription
418FAILUREUnknownSomething went wrong that we don't understand.
1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago