Skip to content

Commit 86515ef

Browse files
committed
Moved base_currency to method level
1 parent ad661b0 commit 86515ef

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/exchangerate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.1"
1+
__version__ = "0.1.2"
22

33
from .config import Region
44
from .client import ExchangerateClient

src/exchangerate/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ class ExchangerateClient:
99
"""
1010
Primary client class
1111
"""
12-
def __init__(self, base_currency="USD", server_region=Region.AMERICA):
13-
self.base_currency = base_currency
12+
def __init__(self, server_region=Region.AMERICA):
1413
self.server_region = server_region
1514
self.session = requests.Session()
1615

1716
# -------------------------------------------------------------------
1817
# Public methods
1918
# -------------------------------------------------------------------
20-
2119
def symbols(self):
2220
"""
2321
Get list of supported symbols
@@ -26,20 +24,23 @@ def symbols(self):
2624
resp_json = self._validate_and_get_json(url)
2725
return resp_json.get("rates")
2826

29-
def latest(self, symbols=None, amount=1):
27+
def latest(self, base_currency="USD", symbols=None, amount=1):
3028
"""
3129
Get latest rate
3230
33-
@param symbols: list of currencies
34-
@param amount: the currency amount
31+
@param base_currency: the base currency
32+
@param symbols: list of currencies, None if including all
33+
@param amount: the currency amount
3534
"""
36-
params = {"amount": amount}
35+
params = {"amount": amount, "base": base_currency}
3736
if symbols: params["symbols"] = ",".join(symbols)
3837

3938
url = self._build_url(path="latest", params=params)
4039
resp_json = self._validate_and_get_json(url)
4140
return resp_json.get("rates")
4241

42+
# -------------------------------------------------------------------
43+
# Private methods
4344
# -------------------------------------------------------------------
4445
def _validate_and_get_json(self, url):
4546
resp = self.session.get(url)

0 commit comments

Comments
 (0)