2.0.6 • Published 3 years ago

scan-package-v2 v2.0.6

Weekly downloads
10
License
ISC
Repository
github
Last release
3 years ago

Brandactif scan package

Getting Started

Those are the instructions on how to use the library:

Prerequisites

  • apiKey - to get access to our api you need to include a key generated by our administrator. To get it, contact us:
  • apiUrl - to get access to our api you need to include a key generated by our administrator. To get it, contact us:
  • npm or yarn - dependency management

Installing

npm:

npm install scan-package-v2

yarn:

yarn add scan-package-v2

Usage

The library accepts arguments:

NameTypeRequiredDescription
apiKeystringRequiredaccess key, to get access contact us
apiUrlstringRequiredapi url, to get access contact us
fileFile image/*RequiredFile from onChange event accepts all types of image
optionsobjectOptionalSee below

options object:

{
  coords: {   //GPS location, it helps us
    long,     //longitude from navigator
    lat,      //latitude from navigator
  },
  deviceId: "", //id of device
  userId: "", //unique ID for PVS campaign
  uuid: "", //unique uuid for personal experience campaign 
  previewHandler: (base64) => { //callback that returns base64 of image you scan
    //... Your code here
  },
  progressHandler: (progress) => { //callback that returns progress of uploading an image - 0 - 100
    //... Your code here
  },
  fetchTimer: //the number of repetitions of fetching redirect_url 
}

To use that package you need to import it first:

import scanPackage from 'scan-package-v2'

Then you can use it on an input type file onChange function:

const options = {
  coords: {
    long: -115.80666344,
    lat: 37.234332396,
  },
  deviceId: "test_deviceId",
  userId: "test_user",
  uuid: "test_uuid",
  previewHandler: preview => {
    console.log(preview) //base64 of uploaded image
  }
}

const handleChange = ({ target: { files } }) => {
  const file = files[0]
  if (!file) {
    throw new Error('File is required')
  }

  scanPackage(apiKey, apiUrl, file, options)
    .then(response => console.log(response))
    .catch(error => console.log(error.message))
}
<input accept="image/*" onChange={handleChange} type="file" />

Built with

  • JavaScript Load Image - The library for resizing / rotating and downsizing images
  • Platform - The library that takes data about device like os, os version, browser etc.
2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago