FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added new forex provider to fix "Currency Rates Source Not Ready" by ShanePadellaro · Pull Request #127 · MicroPyramid/forex-python · GitHub

Added new forex provider to fix "Currency Rates Source Not Ready" - #127

Open
ShanePadellaro wants to merge 2 commits into
MicroPyramid:masterfrom
ShanePadellaro:bugfix/new_api
Open

Added new forex provider to fix "Currency Rates Source Not Ready"#127
ShanePadellaro wants to merge 2 commits into
MicroPyramid:masterfrom
ShanePadellaro:bugfix/new_api

Conversation

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Author

fixes #126

Comment thread 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 Feb 11, 2023
edited
Loading

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Missing sapce before ,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fixed

Comment thread 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)

matech96 Feb 11, 2023
edited
Loading

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Missing sapce before ,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fixed

Comment thread forex_python/converter.py

def _source_url(self):
return "https://theforexapi.com/api/"
return "https://api.exchangerate.host/"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why not allow specying source url as parameter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL