-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRY: Don't Repeat Yourself #123
Conversation
This works since doing an empty return is the same as not doing a return at all in javascript
* Removed “addHeaders” and made repeatable calls to “withHeaders” possible * Made withAuth part of the request builder
Any input @JMPerez? :) |
@brodin Sorry for the late reply. I haven't had time to look into the PRs, and I'm currently looking for adding more maintainers to the project. I like your approach. It's way cleaner and it would make the library lighter and easier to work with. Do you think you'll be able to resolve the conflicts? |
@JMPerez resolved the conflicts now – what do you think? :) |
@brodin It looks great! I'm going to merge it. |
* Moved the optional callback logic to "performRequest" * Refactored header and auth request bulding * Removed “addHeaders” and made repeatable calls to “withHeaders” possible * Made withAuth part of the request builder * Refactored legacy options/callback handler * Don't assign empty object * Refactored query parameters handling * Refactored body parameters handling * Allow multiple arguments to with[body|Query|Headers] builders * Made token part of WebApiRequest builder * A built request can now execute itself * Limit repetition in base-request with factories * Refactored getQueryParameterString and wrote tests for it
Big fan of this repo, but when I looked at the source code to add some new endpoint I realised that there was a lot of repetion in the code. This PR is an attempt to "dry things up". This will not only reduce the footprint of the library, but hopefully make it easier to add and maintain endpoints in the future.
Some of the things I have done:
add[headers|QueryParamaters|BodyParameter]
. This made the built request into a true immutable. This was accomplished by making thewith[Headers|BodyParameter|QueryParamater]
functions more intelligent.Request
(handling both callbacks and promises)WebApiRequest
as a default.What do you guys think? This was kind of a step-by-step refactor, do you want me to squash some of the commits? :)