Commit 86385a1c authored by ryanss's avatar ryanss
Browse files

Implement login method

parent 60d35bf9
......@@ -81,7 +81,7 @@ SugarCRM Objects
API Object
class sugarcrm.API(url, username, password)
class sugarcrm.API(url, username, password, app="Python", lang="en_us")
The main class used to connect to the SugarCRM API and make quests with.
.. code-block:: python
......@@ -126,6 +126,9 @@ get_entry_list(query_object)
for note in notes:
login(username, password, app="Python", lang="en_us")
Logs a user into the SugarCRM application.
Creates or updates a specific object.
......@@ -210,9 +213,6 @@ job_queue_next()
Method not implemented yet.
Method not implemented yet.
Method not implemented yet.
......@@ -17,14 +17,12 @@ import requests
class API:
def __init__(self, url, username, password):
def __init__(self, url, username, password, app="Python", lang="en_us"):
self.url = url
data = [{
'user_name': username,
'password': hashlib.md5(password).hexdigest(),
'version': "1"
result = self._request('login', data)
self.username = username
self.application = app
self.language = lang
result = self.login(username, password)
self.session_id = result['id']
def _request(self, method, params):
......@@ -141,8 +139,20 @@ class API:
def job_queue_run(self):
raise SugarError("Method not implemented yet.")
def login(self):
raise SugarError("Method not implemented yet.")
def login(self, username, password, app="Python", lang="en_us"):
"""Logs a user into the SugarCRM application."""
data = [
'user_name': username,
'password': hashlib.md5(password).hexdigest()
'name': "language",
'value': lang
return self._request('login', data)
def logout(self):
raise SugarError("Method not implemented yet.")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment