lazarus-forms
v1.1.15
Published
Lazarus Forms is a Node.js library that was created to ease the use of integrating Lazarus's Forms API to one's applications.
Downloads
29
Readme
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)
| Parameter | Required | Type | Description | | --- | --- | --- | --- | | sourceType | Yes | string | Used to determine how the file is being passed to the function. Currently only supported values are 'path' and 'file'.| | file | Yes | string/object | If 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)
| Parameter | Required | Type | Description | | --- | --- | --- | --- | | inputUrl | Yes | string | Url to file to extract from: Must be a PDF, JPEG, PNG, or TIFF. | | fileId | No | string | Custom ID for document. If not present, will default to file name. | | metadata | No | object | Custom JSON to be passed as part of the response data. | | webhook | No | string | Webhook 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)
| Parameter | Required | Type | Description | | --- | --- | --- | --- | | sourceType | Yes | string | Used to determine how the file is being passed to the function. Currently only supported values are 'path' and 'file'.| | file | Yes | string/object | If 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)
| Parameter | Required | Type | Description | | --- | --- | --- | --- | | inputUrl | Yes | string | Url to file to extract from: Must be a PDF, JPEG, PNG, or TIFF. | | fileId | No | string | Custom ID for document. If not present, will default to file name. | | metadata | No | object | Custom JSON to be passed as part of the response data. | | webhook | No | string | Webhook 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)
| Parameter | Required | Type | Description | | --- | --- | --- | --- | | inputUrl | Yes | string | Url to file to extract from: Must be a PDF, JPEG, PNG, or TIFF. | | outputUrl | Yes | string | Url where to send output zip file. Must be open to PUT requests. | | outputUrlHeaders | No | object | Json with headers to be sent to your outputUrl. | | fileId | No | string | Custom ID for document. If not present, will default to file name. | | metadata | No | object | Custom JSON to be passed as part of the response data. | | webhook | No | string | Webhook 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
| Response | Status | Meaning | Description | | --- | --- | --- | --- | | 400 | FAILURE | Bad Request | bad request and failure to read | | 401 | AUTH_FAILURE | Unauthorized | unauthorized attempt | | 403 | FAILURE | Forbidden | invalid subscription | | 418 | FAILURE | Unknown | Something went wrong that we don't understand. |