xtuple/xtuple-nodejs-rest-client

Name: xtuple-nodejs-rest-client

Owner: xTuple

Description: This repository contains the source code for the Node.js REST API client library for xTuple. The client library uses the Google API client library for Node.js.

Created: 2014-07-21 05:34:34.0

Updated: 2017-01-24 10:55:46.0

Pushed: 2014-11-17 16:43:55.0

Homepage:

Size: 290

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

xTuple ERP Node.js REST API Client Library

xTuple ERP Node.js REST API Client Library using the Google APIs Client Library for Node.js. For more information about xTuple's web application, look at the source code. You can also find an example Node.js REST API cient here.

NPM version

Usage:
Create new OAuth2 Client in xTuple

Before you can use this client with xTuple's OAuth 2.0 Server, you need to install the OAuth 2.0 extension in your xTuple application and create a reference for a new OAuth 2.0 Client. Be sure to select a “Client Type” of “Service Account” and ensure that “Delegated Access” is checked. This will generate a private key and give you all the other information that you wll need to connect to the xTuple REST API.

Installation

Clone this repository and run npm install

or npm install xtuple-rest-client

Set your Private Key

Convert your key.p12 file to key.pem and copy it to the keys folder:

openssl pkcs12 -in keys/key.p12 -nocerts -nodes | openssl rsa -out keys/key.pem

This key and the folder are in the .gitignore and should never be committed to source control.

Enter Import Password: 'notasecret'

Setup Environment Variables

cp sample.env .env

Open the .env file and change the information to match what was provided by the xTuple OAuth 2.0 extension. This .env file should also never be committed to source control.

Example Use
_ = require('underscore'),
ient = require('xtuple-rest-client');

Client(function (client) {
ient.query({
type: 'ToDo',
method: 'list',
params: { maxResults: 50 },
callback: function (err, result) {
  if (err) {
    console.log('Error:', err);
  }
  if (result) {
    console.log('To Dos:');
    _.map(result.data.data, function (obj) {
      console.log('Id:', obj.uuid);
      console.log('Name:', obj.name);
      console.log('Description:', obj.description);
    });
  }
}
;

License

Apache License, Version 2.0

Copyright (c) 2012-2013 xTuple http://www.xtuple.com/


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.