GithubHelp home page GithubHelp logo

fishbowl-js's Introduction

Fishbowl-js

The JavaScript wrapper for the Fishbowl API

npmDownloads

NPM

Request options

Reference src/requestTypes.ts to learn option parameters for the different requests

Fishbowl API

If you have questions regarding the actual Fishbowl API please visit the Fishbowl API wiki

Donate

Feel free to donate to support Fishbowl-js! This project is Open Source and is not affiliated with Fishbowl Inventory.

Usage

The default options for the constructor are

const fb = new Fishbowl({
    host: '127.0.0.1',
    port: 28192,
    IAID: 54321,
    IAName: 'Fishbowljs',
    IADescription: 'Fishbowljs helper',
    username: 'admin',
    password: 'admin',
    useLogger: true
  });

You may pass a callback function to the constructor to know if it connected properly

const fb = new Fishbowl({}, (err, res) => {
  if (err) {
    console.log(err);
    return;
  }
});

To use async await use the sendRequestPromise({ req, options, json }) function

const executeQuery = async () => {
  try {
    const part = await fb.sendRequestPromise({ req: 'ExecuteQueryRq', options: { query: 'select * from part where num = "B201"' } });
    const product = await fb.sendRequestPromise({ req: 'ExecuteQueryRq', options: { query: 'select * from product where num = "B202"' } });
    console.log(`Part: ${part}`);
    console.log(`Product: ${product}`);
  } catch (err) {
    console.log(`Err: ${err.code} - ${err.message}`);
  }
}

executeQuery();

All requests by default will send back the data in JSON format.

fb.sendRequest({ req: 'ExecuteQueryRq', options: { query: "select * from part where num='B201'" } }, (err, res) => {
  if (err) {
    console.log(`Err: ${err.code} - ${err.message}`);
    return;
  }

  console.log(`Data: ${res}`);
});

If the request allows it and you desire it, the request could send the data back in CSV format. Notice the json flag as the third attribute in the RequestOptions.

fb.sendRequest({ req: 'ExecuteQueryRq', options: { query: "select * from part where num='B201'" }, json: false }, (err, res) => {
 if (err) {
   console.log(`Err: ${err.code} - ${err.message}`);
   return;
 }

 console.log(`Data: ${res}`);
});

All valid API requests are accepted, not only the requests documented on the Fishbowl API wiki

fb.sendRequest({req: 'PartGetRq', options: { Number: 'B201', GetImage: false } }, (err, res) => {
 if (err) {
   console.log(`Err: ${err.code} - ${err.message}`);
   return;
 }

 console.log(`Data: ${res}`);
});
const Fishbowl = require('fishbowl-js');

const fb = new Fishbowl({}, (err, res) => {
  if (err) {
    console.log(err);
    return;
  }
});

// If you have already approved this integration, this will be seamless.
// If you have not approved the integration, you will need to approve it and then send the login request again.
fb.sendRequest({ req: 'LoginRq' });

const partImport = [
  {
    partNumber: '1API',
    partDescription: 'Fishbowl-js',
    partDetails: '',
    uom: 'ea',
    upc: '',
    partType: 'Inventory',
    active: 'true',
    abcCode: 'N',
    weight: '210',
    weightUom: 'lbs',
    width: '0',
    height: '0',
    length: '0',
    sizeUom: 'ft',
    primaryTracking: '',
    alertNote: '',
    pictureUrl: '',
    poItemType: 'Purchase',
    'Tracks-Lot Number': 'false',
    'Tracks-Revision Level': 'false',
    'Tracks-Expiration Date': 'false',
    'Tracks-Serial Number': 'false'
  },
  {
    partNumber: '2API',
    partDescription: 'Fishbowl-js2',
    partDetails: '',
    uom: 'ea',
    upc: '',
    partType: 'Inventory',
    active: 'false',
    abcCode: 'N',
    weight: '210',
    weightUom: 'lbs',
    width: '0',
    height: '0',
    length: '0',
    sizeUom: 'ft',
    primaryTracking: '',
    alertNote: '',
    pictureUrl: '',
    poItemType: 'Purchase',
    'Tracks-Lot Number': 'false',
    'Tracks-Revision Level': 'false',
    'Tracks-Expiration Date': 'false',
    'Tracks-Serial Number': 'false'
  }
];

fb.sendRequest({ req: 'ImportRq', options: { type: 'ImportPart', row: partImport } }, (err, res) => {
  if (err) {
    console.log(`err: ${err.code} - ${err.message}`);
    return;
  }

  console.log(`Data: ${res}`);
});

fb.sendRequest({ req: 'IssueSORq', options: { soNumber: '50053' } });

const executeQuery = async () => {
  try {
    const part = await fb.sendRequestPromise({ req: 'ExecuteQueryRq', options: { query: "select * from part where num='B201' or num='B202' or num='1API'" }, json: false });
    const product = await fb.sendRequestPromise({ req: 'ExecuteQueryRq', options: { query: "select * from product where num = 'B202'" } });
    console.log(`Part: ${part}`);
    console.log(`Product: ${product}`);
  } catch (err) {
    console.log(`Err: ${err.code} - ${err.message}`);
  }
}

executeQuery();

fishbowl-js's People

Contributors

brennenrocks avatar dallenbaldwin avatar ddevoss avatar p2pb avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.