Added new forex provider to fix "Currency Rates Source Not Ready"#127
Open
ShanePadellaro wants to merge 2 commits intoMicroPyramid:masterfrom
Open
Added new forex provider to fix "Currency Rates Source Not Ready"#127ShanePadellaro wants to merge 2 commits intoMicroPyramid:masterfrom
ShanePadellaro wants to merge 2 commits intoMicroPyramid:masterfrom
Conversation
Author
|
fixes #126 |
matech96
reviewed
Feb 11, 2023
forex_python/converter.py
Outdated
| return date_str | ||
|
|
||
| def _decode_rates(self, response, use_decimal=False, date_str=None): | ||
| def _decode_rates(self, response, use_decimal=False, date_str=None,base_cur=None): |
matech96
reviewed
Feb 11, 2023
forex_python/converter.py
Outdated
| response = requests.get(source_url, params=payload) | ||
| if response.status_code == 200: | ||
| rates = self._decode_rates(response, date_str=date_str) | ||
| rates = self._decode_rates(response,date_str=date_str,base_cur=base_cur) |
brtkwr
reviewed
Feb 13, 2023
|
|
||
| def _source_url(self): | ||
| return "https://theforexapi.com/api/" | ||
| return "https://api.exchangerate.host/" |
There was a problem hiding this comment.
why not allow specying source url as parameter?
Author
There was a problem hiding this comment.
Most apis are not going to be this similar in terms of api surface. This one is 95% there so still requires minor changes. I don't think having the provider url as a parameter makes sense unless theforexapi.com comes back online again.
If supporting multiple apis is required there needs to be some refactoring to abstract the api provider from the currency class.
There was a problem hiding this comment.
It makes sense, you can host your own api since theforexapi is open source, there should be an option to override the url...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added forex provider (exchangerate.host) which is almost a 1to1 replacement for the old theforexapi.com.
Added a check to throw if a currency is not available since new provider always returns 200
All unit tests for converter.py are working a part from test_with_valid_currency_code which looks to be broken because the included json file doesn't contain the expected symbol.