robinpowered/robin-js-sdk-public

Update this SDK to be inline with current API docs

Opened this issue · 3 comments

For example, there's a call to POST /spaces/:id/events for reserving a room, but this SDK appears not to support it.

Am I missing something? I'd expect to be able to do:

robin.api.spaces.events.create(spaceId, eventData)

I looked around, didn't see anything, so here's a patch.

Thanks for the report. We're due for some spring cleaning on this SDK's convenience methods.

In the meantime, you can call endpoints without direct support via the following convention:

sdk.api.POST(`/events/${eventID}`, params).then(response => response.getData());
sdk.api.GET(`/events/${eventID}`).then(response => response.getData());
// etc.

Ref:

  • https://github.com/robinpowered/robin-js-sdk#instantiation-with-a-default-options-object
  • /**
    * Implement HTTP request methods, to make requests easier
    */
    RequestBase.prototype.GET = function (path, params) {
    return this.sendRequest(path, 'GET', params);
    };
    RequestBase.prototype.HEAD = function (path, params) {
    return this.sendRequest(path, 'HEAD', params);
    };
    RequestBase.prototype.POST = function (path, data) {
    return this.sendRequest(path, 'POST', data);
    };
    RequestBase.prototype.PUT = function (path, data) {
    return this.sendRequest(path, 'PUT', data);
    };
    RequestBase.prototype.PATCH = function (path, data) {
    return this.sendRequest(path, 'PATCH', data);
    };
    RequestBase.prototype.DELETE = function (path, data) {
    return this.sendRequest(path, 'DELETE', data);
    };
    RequestBase.prototype.OPTIONS = function (path, data) {
    return this.sendRequest(path, 'OPTIONS', data);
    };

👍 on adding the /free-busy/spaces endpoint as well.