kwent / syno

Simple Node.js wrapper and CLI for Synology DSM REST API 5.x and 6.x.
http://kwent.github.io/syno
MIT License
316 stars 51 forks source link

How to control the version in the request? #29

Open kimpenhaus opened 7 years ago

kimpenhaus commented 7 years ago

First of all - thanks for implementing - that saved me a lot of work and its usage is really straight forward.

But I do have a question about the control of the request version (not that of the API). I am trying to enable/disable a camera based on an event. I know that the surveillance api has the possibility to since v3 (based on your _full.json)

By default it looks to me that it is always using v1 - because of this: version = 'minVersion' in definitions[api] ? definitions[api].minVersion : 1;

So I changed the min version to 8, which actually helps me with this problem but opens up another one :) getInfoCamera changed its response data between those versions 1 and 8.

So what I am trying is to control the version on each request. So that I can go with v1 on getInfoCamera and with v8 on enableCamera/disableCamera.

Is that possible? And what is the recommended way to enable a specific version - I don't think changing the minor version in the _full.json is the recommended one ;-)

Thanks and have a happy new year! m.

kwent commented 7 years ago

Very interesting. It's true it's not possible for now.

I should be able to implement a flag to be able to control this version.

I also think it should be maxVersion by default and not minVersion.

kimpenhaus commented 7 years ago

Maybe an options array containing meta data for the request makes sense. Not sure if there will be ever more than a version to control...

Thanks.

kwent commented 7 years ago

What about ?

In JS

# For a call with API version 2
syno.api(2).method(params, callback);
# Call with last API version
syno.api.method(params, callback);

In CLI

# For a call with API version 2
syno api --version 2 method;
# For a call with las API version
syno api method;
kimpenhaus commented 7 years ago

wow - yeah that looks pretty cool and intuitive. I vote +1 for that!