Giter Site home page Giter Site logo

siptwo's People

Contributors

jblyberg avatar otuoma avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

otuoma

siptwo's Issues

SipTwo library issues

Dependency dateformat causing issue Error [ERR_REQUIRE_ESM]: require() of ES Module inside the module
node_modules\siptwo\dist\lib\helpers\DateTimeHelpers.js:4
const dateFormat = require("dateformat");

Item checkin not returning any response

It seems there is an issue with item checkin. I have the following code in express

router.get('/checkin',  async (req: Request, res: Response) => {

   const item_barcode: string = `${req.query.item_barcode}`;

   if (!item_barcode) {
       return res.status(400).send("Item barcode is required");
   }
   const sipTwo = new SipTwo(sip2ConnectionOptions);
   // sipTwo.setPatron({
   //     patronIdentifier: "123456",
   //     password: "demopass"
   // });
   try {
       await sipTwo.login();
       let datetime_now = new Date(); //getFormattedDated();
       let checkinRequestDto: ICheckinRequestDto = {
           location: sip2ConnectionOptions.institutionId,
           offline: false,
           returnDate: datetime_now,
           itemIdentifier: item_barcode
       };
       const checkinResponse: ICheckinResponse = await sipTwo.requestCheckin(checkinRequestDto);
       sipTwo.connection.close();
       res.status(200).send(checkinResponse);
   } catch (e) {
       console.log(e);
       sipTwo.connection.close();
       res.status(500).send("Error: Internal Server Error");
   }
});

There is no response from the server, ever.

However, if a non-existing item identifier is provided, then we get Invalid Item response, which is expected.

I tested with the sip-testing-tool on the same sip server and was able to check-in the same item.

There could be an awaitable that is not being awaited and I have not been able to fix it. @jblyberg

TypeError: Cannot read properties of undefined (reading 'sequence')

I am testing out the new code release and have setup my project as follows but encounters the error mentioned.

`
import express, { Request, Response } from 'express';
import { SipTwo, ISip2ConnectionOptions, IPatronCredentials } from 'siptwo';

const app = express();
const PORT = 3000;

const sip2ConnectionOptions: ISip2ConnectionOptions = {
    host: '172.20.22.876',
    port: 6001,
    username: 'DemoUser',
    password: 'DemoUser22',
    institutionId: 'CPL',
    language: 'English',
    timeout: 60,
    maxListeners: 5,
};

const patronCredentials: IPatronCredentials = {
    patronIdentifier: '123456',
    password: 'DemoUser22',
    institutionId: sip2ConnectionOptions.institutionId
};

const sipTwo = new SipTwo(sip2ConnectionOptions);
app.get('/', (req: Request, res: Response) => {

    // Inside an async function/method
    (async () => {
        await sipTwo.login();

        sipTwo.setPatron(patronCredentials);
        const patronInfo = await sipTwo.requestPatronInformation();
        console.log('patronInfo', patronInfo);
        sipTwo.connection.close();
    })();

    res.send('Hello, TypeScript Express!');
});

app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
});

`

Above code throws the error below

`
TypeError: Cannot read properties of undefined (reading 'sequence')
at new LoginRequest (C:\projects\siptwo\node_modules\siptwo\src\lib\requests\LoginRequest.ts:8:38)
at SipTwo.login (C:\projects\siptwo\node_modules\siptwo\src\lib\SipTwo.ts:71:26)
at C:\projects\siptwo\src\index.ts:29:22
at Generator.next ()
at C:\projects\siptwo\src\index.ts:8:71
at new Promise ()
at __awaiter (C:\projects\siptwo\src\index.ts:4:12)
at C:\projects\siptwo\src\index.ts:28:17
at C:\projects\siptwo\src\index.ts:35:7
at Layer.handle [as handle_request] (C:\projects\siptwo\node_modules\express\lib\router\layer.js:95:5)

`

@jblyberg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.