Mik13/nuki-bridge-api

Avoid library information in payload

Closed this issue · 4 comments

Zefau commented

Hi there,

I was wondering if it is possible to avoid the additional data created by this library in the course of payload retrieval from the actual Nuki API.

Specifically, the function getCallbacks() returns for me:

[
   {
      "_events":{

      },
      "_eventsCount":0,
      "_maxListeners":100,
      "connection":{
         "ip":"192.168.178.40",
         "port":8080,
         "token":"...",
         "delayBetweenRequests":250,
         "delayer":{
            "isFulfilled":false,
            "isRejected":false
         }
      },
      "callbackId":0,
      "url":"http://192.168.178.29:51987/nuki-api-bridge"
   },
   {
      "_events":{

      },
      "_eventsCount":0,
      "_maxListeners":100,
      "connection":{
         "ip":"192.168.178.40",
         "port":8080,
         "token":"...",
         "delayBetweenRequests":250,
         "delayer":{
            "isFulfilled":false,
            "isRejected":false
         }
      },
      "callbackId":1,
      "url":"http://192.168.178.29:51988/nuki-api-bridge"
   }
]

but an Array of Objects with the indices callbackId and url is sufficient, e.g.

[
   {
      "callbackId":0,
      "url":"http://192.168.178.29:51987/nuki-api-bridge"
   },
   {
      "callbackId":1,
      "url":"http://192.168.178.29:51988/nuki-api-bridge"
   }
]

Would it be possible to change this?

Thanks and kind regards,
Zefau

Mik13 commented

Hi!

Yea, sounds reasonable. I will look into that when implementing the other feature. Thanks for the idea!

Best regards!

Mik13 commented

I've looked into it, and getCallbacks does not return plain objects, but instances of Callback, which is an eventemitter.

Thats why the array seems so messy.

If you want/need only this two properties, you can implement a function in Callback.prototype which returns them.

Zefau commented

See pr #15

Mik13 commented

Merged. Thanks very much.

I will look into the other issues and PRs and will publish a new version after this.