0.1.1 • Published 8 years ago

sip2 v0.1.1

Weekly downloads
15
License
ISC
Repository
github
Last release
8 years ago

SIP2 communication for Node.js

Installation

$ npm install sip2

Usage

const async = require('async');
const SIP2 = require('sip2');
const sip2connection = new SIP2.Connection(host, port);

function connect(cb) {
  sip2connection.connect(cb);
}

function requestLogin(cb) {
  // Login request
  const loginRequest = new SIP2.LoginRequest(username, password);
  loginRequest.sequence = 1;
  sip2connection.send(loginRequest.getMessage(), cb);
}

function requestPatronInformation(loginResponse, cb) {
  if (!loginResponse.ok) {
    return cb(new Error('Could not login'));
  }
  // Patron information request
  const type = 'hold';
  const patronInformationRequest = new SIP2.PatronInformationRequest(type, 1, 2);
  patronInformationRequest.sequence = 2;
  patronInformationRequest.institutionId = 'OBA';
  patronInformationRequest.patronIdentifier = '900000001025';
  sip2connection.send(patronInformationRequest.getMessage(), cb);
}

async.waterfall([
  connect,
  requestLogin,
  requestPatronInformation,
], (err, patronInformationResponse) => {
  console.log(err, patronInformationResponse);
});

Tests

To run the test suite, first install the dependencies, the run npm test:

$ npm install
$ npm test
0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago

1.0.0

8 years ago