Skip to content
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

Merged
merged 14 commits into from
Sep 4, 2017
Merged

DRY: Don't Repeat Yourself #123

merged 14 commits into from
Sep 4, 2017

Conversation

brodin
Copy link
Contributor

@brodin brodin commented Apr 25, 2017

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:

  • Remove the notion of add[headers|QueryParamaters|BodyParameter]. This made the built request into a true immutable. This was accomplished by making the with[Headers|BodyParameter|QueryParamater] functions more intelligent.
  • Made execution part of the Request (handling both callbacks and promises)
  • Made authentication part of the 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? :)

@brodin
Copy link
Contributor Author

brodin commented Apr 28, 2017

Any input @JMPerez? :)

@JMPerez
Copy link
Collaborator

JMPerez commented Aug 24, 2017

@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?

@brodin
Copy link
Contributor Author

brodin commented Sep 4, 2017

@JMPerez resolved the conflicts now – what do you think? :)

@JMPerez
Copy link
Collaborator

JMPerez commented Sep 4, 2017

@brodin It looks great! I'm going to merge it.

@JMPerez JMPerez merged commit 9ccbbe2 into thelinmichael:master Sep 4, 2017
atoami pushed a commit to atoami/react-native-spotify-web-api that referenced this pull request Oct 20, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants