Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ fenix_python_sdk
#### Instantiating the client
* Instantiate an API client object in your source code

<code>client = fenixedu.FenixEduClient(config)</code>
<code>client = fenixedu.FenixEduClient(config, LOCALE)</code>

where LOCALE is an optional argument. LOCALE can be 'pt-PT' or 'en-GB'.


### Authentication

Expand Down
8 changes: 5 additions & 3 deletions fenixedu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@

class FenixEduClient(object):

def __init__(self, config):
def __init__(self, config, local = None):
self.config = config
self.api_url = self.config.base_url + self.config.api_endpoint + 'v' + str(self.config.api_version)
self.oauth_url = self.config.base_url + endpoints.OAUTH

self.locale = locale

def _get_api_endpoint_url(self, endpoint, endpoint_params=None):
url = self.api_url + '/' + endpoint
if endpoint_params:
for key, value in endpoint_params.items():
url = url.replace(':' + key, str(value), 1)

if self.locale:
url = url + '?lang=' + str(self.locale)
return url

def _get_oauth_endpoint_url(self, endpoint):
Expand Down