cronofy / cronofy-node

Node wrapper for the Cronofy API
https://docs.cronofy.com/developers
MIT License
49 stars 23 forks source link

Single file held state #23

Closed Haziba closed 7 years ago

Haziba commented 7 years ago

Note to tester: Rejigged everything so state can be both held by the client and overwritten in each method call

AdriVanHoudt commented 7 years ago

This is a way nicer implementation :D 👌

Haziba commented 7 years ago

Sound like some good changes to make, from looking at the next_page situation however I feel like the SDK would benefit from an iterator so that the pagination is handled from inside the Cronofy object?

Also I'm hesitant to make a breaking change to the error handling but currently we're passing back the whole response as the error, whereas I believe it would be better to just pass back the status code and the response body, so that whoever is using this client will just get the information they need and have an easier time working out what the issue is with a failing call.

What do you think to both these points?

AdriVanHoudt commented 7 years ago
Haziba commented 7 years ago

@AdriVanHoudt How's that?

AdriVanHoudt commented 7 years ago

Are you sure that the current implementation does the prototype thing? I think you are still setting all the methods on creating a new instance. Instead of reusing them for each instance. What you want to do (I think) is

var cronofy = function cronofy(config) {
     this.config = config;
};

cronofy.prototype.readEvents = function (...) {...};

Does that make sense or am I missing the ball here?

Haziba commented 7 years ago

Ah sorry I misunderstood! JavaScript isn't my primary language so I'm not quite so knowledgable on prototypes and the like, so thanks very much for your help :)

Does this look alright now?

Haziba commented 7 years ago

@AdriVanHoudt How's that?

AdriVanHoudt commented 7 years ago

Seems good 👍