sip2

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i sip2

Weekly Downloads

25

Version

0.1.1

License

ISC

Last publish

Collaborators

  • frankdsm
  • stefanpante