# 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.

Latest version **1.1.15** (published 2022-03-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install lazarus-forms
pnpm add lazarus-forms
yarn add lazarus-forms
bun add lazarus-forms
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.15 |
| Published | 2022-03-25 |
| First published | 2022-03-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | anishp16 |

## Links

- npm: https://www.npmjs.com/package/lazarus-forms
- npm.io page: https://npm.io/package/lazarus-forms

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.26.0
- [form-data](https://npm.io/package/form-data.md) ^4.0.0

## Recent versions

- 1.1.15 (latest) — 2022-03-25
- 1.1.14 — 2022-03-24
- 1.1.13 — 2022-03-15
- 1.1.12 — 2022-03-14
- 1.1.11 — 2022-03-10
- 1.1.10 — 2022-03-10
- 1.1.9 — 2022-03-07
- 1.1.8 — 2022-03-07
- 1.1.7 — 2022-03-07
- 1.1.6 — 2022-03-07
- 1.1.5 — 2022-03-07
- 1.1.4 — 2022-03-07
- 1.1.3 — 2022-03-07
- 1.1.2 — 2022-03-04
- 1.1.1 — 2022-03-03
- … 1 more at https://npm.io/package/lazarus-forms/versions

## 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](https://www.lazarusforms.com/).

## 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](https://api.lazarusforms.com/docs#upload-a-file-via-multipart-form-get-back-a-json)

**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](https://api.lazarusforms.com/docs#upload-a-url-via-json-get-back-a-json)

**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](https://api.lazarusforms.com/docs#upload-a-file-via-multipart-form-get-back-a-zip-file)

To save the file if it is being returned client-side: using a package such as [file-saver](https://www.npmjs.com/package/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](https://api.lazarusforms.com/docs#upload-a-url-via-json-get-back-a-zip-file)

To save the file if it is being returned client-side: using a package such as [file-saver](https://www.npmjs.com/package/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](https://api.lazarusforms.com/docs#upload-a-url-via-json-get-back-a-zip-file)

**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](https://http.cat/400) | bad request and failure to read |
| 401 | AUTH_FAILURE | [Unauthorized](https://datatracker.ietf.org/doc/html/rfc7235#section-3.1) | unauthorized attempt |
| 403 | FAILURE | [Forbidden](https://http.cat/403) | invalid subscription |
| 418 | FAILURE | [Unknown](https://http.cat/418) | Something went wrong that we don't understand.	 |

---
_Source: https://npm.io/package/lazarus-forms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
