architv / soccer-cli

:soccer: Football scores for hackers. :computer: A command line interface for all the football scores.
MIT License
1.09k stars 221 forks source link

Improved handling of API request status codes #63

Closed Saturn closed 8 years ago

Saturn commented 8 years ago

This handles dealing with http status codes once instead of having to deal with them on every single api calling function.

Uses new _get function that wraps requests.get. This is just for making calls to api.football-data.org as you will notice the get_live_scores function remains untouched as it is a different API.

Every function should have the same effect mostly. Just instead of checking if the status_code is ok on each function, it now checks it once.

Also instead of composing the base_url + headers=headers on each function, it will just do this once.

This should make the api functions a bit cleaner and easier to test. Not all api calling situations are correctly accounted for but this is a step in the right direction in my opinion.

architv commented 8 years ago

This makes a lot of sense. +1