Skip to content

Commit 458d788

Browse files
committed
Add domain specific api url
1 parent f743328 commit 458d788

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mailjet_rest/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212

1313

1414
class Config(object):
15-
API_URL = 'https://api.mailjet.com/'
15+
DEFAULT_API_URL = 'https://api.eu.mailjet.com/'
1616
API_REF = 'http://dev.mailjet.com/email-api/v3/'
1717
version = 'v3'
1818
user_agent = 'mailjet-apiv3-python/v' + get_version()
1919

20-
def __init__(self, version=None):
20+
def __init__(self, version=None, api_url=None):
2121
if version is not None:
2222
self.version = version
23+
self.api_url = api_url or self.DEFAULT_API_URL
2324

2425
def __getitem__(self, key):
25-
url = self.API_URL[0:]
26+
url = self.api_url[0:]
2627
# Append version to URL.
2728
# Forward slash is ignored if present in self.version.
2829
url = urljoin(url, self.version + '/')
@@ -75,7 +76,8 @@ class Client(object):
7576
def __init__(self, auth=None, **kwargs):
7677
self.auth = auth
7778
version = kwargs.get('version', None)
78-
self.config = Config(version=version)
79+
api_url = kwargs.get('api_url', None)
80+
self.config = Config(version=version, api_url=api_url)
7981

8082
def __getattr__(self, name):
8183
split = name.split('_')

0 commit comments

Comments
 (0)