Skip to content

communico/node-sip2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 then run npm test:

$ npm install
$ npm test

About

SIP2 communication for Node.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%