diff --git a/mercury_bank_api/mercury_client.py b/mercury_bank_api/mercury_client.py index 42dbc5c..cec7b38 100644 --- a/mercury_bank_api/mercury_client.py +++ b/mercury_bank_api/mercury_client.py @@ -28,9 +28,10 @@ class MercuryBankAPIClient: transactions = client.get_transactions(account_id="account_123") """ - BASE_URL = "https://api.mercury.com/api/v1" + base_url = "https://api.mercury.com/api/v1" + SANDBOX_BASE_URL = "https://api-sandbox.mercury.com/api/v1" - def __init__(self, api_token: str, timeout: int = 30): + def __init__(self, api_token: str, timeout: int = 30, sandbox: bool = False): """ Initialize the Mercury Bank API client. @@ -38,6 +39,8 @@ def __init__(self, api_token: str, timeout: int = 30): api_token: Your Mercury API token timeout: Request timeout in seconds (default: 30) """ + if sandbox: + self.base_url = self.SANDBOX_BASE_URL self.api_token = api_token self.timeout = timeout self.session = requests.Session() @@ -76,7 +79,7 @@ def _make_request( Raises: MercuryBankAPIError: If the API request fails """ - url = urljoin(self.BASE_URL + "/", endpoint.lstrip("/")) + url = urljoin(self.base_url + "/", endpoint.lstrip("/")) try: response = self.session.request( diff --git a/pyproject.toml b/pyproject.toml index 8ab7349..cb56829 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mercury_bank_api" -version = "1.0.0" +version = "1.0.2" description = "A comprehensive Python client for the Mercury Bank API" readme = "README.md" license = "MIT" diff --git a/setup.py b/setup.py index 77ecd89..2e7bb65 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,6 @@ The main configuration is in pyproject.toml. """ -from setuptools import setup +from setuptools import setup # type: ignore setup()