1.4.1 • Published 3 years ago

qpm-client-js v1.4.1

Weekly downloads
50
License
ISC
Repository
-
Last release
3 years ago

Quick Pallet Maker - Client Js

Description

qpm-client-js It is a library that communicates with the Quick Pallet Maker server, it uses the methods already established in the QPM API documentation (http://45.79.44.19:8888/QPMCalcServer/api/)

Install with NPM

npm install qpm-client-js

Example with Login

// importing library qpm-client-js
const { QPM } = require("qpm-client-js");


// instance library QPM
const Client = QPM();

// login data user this return an object with data user that id, site, user_leve, others ...
Client.login({
    "username": "user_example", // username
    "password": "password_example", // password
    "server": "https://mi-server.com:8000" // link and port the server
    "calcdb": "qpm_calcdb", // calcdb: the name of the data source for the calculation database.
    "ctrldb": "qpm_controldb" // controldb: the name of the data source for the control database.
});

Using before setting, you request data to serve. example:

function not async in javascript

// function not async
function requestAddClassVariable() {
  // function recibe response
  const handleResponse = function (response) {
    console.log(response);
  };

  // Client.method("name_method", { params })
  Client.method('addEditAssetClass', {
    classinfo: {
      site_name: 'San Jose CR',
      asset_class: 'Test1 - erik',
      asset_description: 'Description - test - 1 ',
      asset_text: '1',
      level: 2,
    },
  });

  // request data on server and
  // execute handleResponse before declared
  Client.fetch().then(handleResponse);
}

function async in javascript

// creating function async
async function addAssetClass() {
  // Client.method( "name_method", { params })
  Client.method('addEditAssetClass', {
    classinfo: {
      site_name: 'San Jose CR',
      asset_class: 'Test1 - erik',
      asset_description: 'Description - test - 1 ',
      asset_text: '1',
      level: 2,
    },
  });

  // request data on function async
  let asset = await Client.fetch().then(t => t);
  console.log('asset', asset);
}

Example Not Login

// importing library qpm-client-js
const { QPM } = require('qpm-client-js');

// loading setting for comunication API Quick Pallet Maker
const Client = QPM({
  username: 'user_example', // username
  password: 'password_example', // password
  server: 'https://mi-server.com:8000', // link and port the server
});

Using before setting, you request data to serve. example:

function not async in javascript

// function not async
function requestAddClassVariable() {
  // function recibe response
  const handleResponse = function (response) {
    console.log(response);
  };

  // Client.method("name_method", { params })
  Client.method('addEditAssetClass', {
    classinfo: {
      site_name: 'San Jose CR',
      asset_class: 'Test1 - erik',
      asset_description: 'Description - test - 1 ',
      asset_text: '1',
      level: 2,
    },
  });

  // request data on server and
  // execute handleResponse before declared
  Client.fetch().then(handleResponse);
}

function async in javascript

// creating function async
async function addAssetClass() {
  // Client.method( "name_method", { params })
  Client.method('addEditAssetClass', {
    classinfo: {
      site_name: 'San Jose CR',
      asset_class: 'Test1 - erik',
      asset_description: 'Description - test - 1 ',
      asset_text: '1',
      level: 2,
    },
  });

  // request data on function async
  let asset = await Client.fetch().then(t => t);
  console.log('asset', asset);
}

The above example is based on the following link in the QPM API documentation http://45.79.44.19:8888/QPMCalcServer/api/classes/addClassVariable.cfm

1.4.1

3 years ago

1.4.0

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.1.2

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago