added currency conversion to the CurrencyConversion class

This commit is contained in:
nathan koch 2019-12-08 15:54:09 -05:00
parent 71caae03f9
commit f1a4a93a41

View file

@ -27,6 +27,14 @@ class CurrencyConverter(object):
currencies.append((rate,rate))
return currencies
def echange_currency(self,amount,currency1,currency2):
base = self.response["base"]
conversion_rate1 = self.response["rates"][currency1]
conversion_rate2 = self.response["rates"][currency2]
new_amount = (amount / conversion_rate1) * conversion_rate2
# round to two digits because we are dealing with money
return round(new_amount,2)
def slugify(value):
"""Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.