Skip to content

How to respond to an Orca Scan Lookup request using Java

License

Notifications You must be signed in to change notification settings

orca-scan/orca-lookup-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

orca-lookup-java

This open source project is a an example of how to scan barcodes using a smartphone and present data from your system using Java and the spring framework.

How it works:

  1. A user scans a barcode using their smartphone
  2. Orca Scan sends a HTTP GET request to your endpoint with ?barcode=value
  3. Your system queries a database or internal API for a barcode match
  4. Your system returns the data in JSON format with keys matching column names
  5. The Orca Scan mobile app presents that data to the user

If the mobile user has update permission and saves the data, it will saved to your Orca sheet.

Install

First ensure you have Java installed:

# should return 1.7 or higher
java -version

Also ensure you have Maven installed:

# should return 3.8.5 or higher
mvn -v

Then execute the following:

# download this example code
git clone https://github.com/orca-scan/orca-lookup-java.git

# go into the new directory
cd orca-lookup-java

# install dependencies
mvn install

Run

mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=5000

Visit http://localhost:5000?barcode=4S3BMHB68B3286050 to see the following:

{
    "VIN": "4S3BMHB68B3286050",
    "Make": "SUBARU",
    "Model": "Legacy",
    "Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
    "Vehicle Type": "PASSENGER CAR",
    "Year": 1992
}

How this example works

@RequestMapping(value = "/", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public HashMap<String, Object> Lookup(String barcode) {

    // TODO: query a database or API to retrieve some data based on barcode value

    // return data as JSON object (property names must match Orca column names)
    HashMap<String, Object> data = new HashMap<>();
    data.put("VIN", barcode);
    data.put("Make", "SUBARU");
    data.put("Model", "Legacy");
    data.put("Manufacturer Name", "FUJI HEAVY INDUSTRIES U.S.A");
    data.put("Vehicle Type", "PASSENGER CAR");
    data.put("Year", 1992);

    return data;
}

Troubleshooting

If you run into any issues not listed here, please open a ticket.

Examples in other langauges

History

For change-log, check releases.

License

Licensed under MIT License © Orca Scan, the Barcode Scanner app for iOS and Android.

About

How to respond to an Orca Scan Lookup request using Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages