Commit 38c78f8d authored by ryanss's avatar ryanss
Browse files

Implement get_available_modules method

parent 86385a1c
......@@ -93,6 +93,16 @@ class sugarcrm.API(url, username, password, app="Python", lang="en_us")
API Methods
-----------
get_available_modules(filter="default")
Retrieves a list of available modules in the system.
Possible filter values: "default", "mobile", "all"
.. code-block:: python
modules = sugar.get_available_modules()
for m in modules:
print m.module_key
get_entry(module, object_id, track_view=False)
Retrieves a single object based on object ID.
......@@ -150,9 +160,6 @@ set_note_attachment(note, attachment)
sugar.set_note_attachment(note2, "test2.pdf")
print note1.filename, note2.filename
get_available_modules()
Method not implemented yet.
get_document_revision()
Method not implemented yet.
......
......@@ -38,8 +38,17 @@ class API:
raise SugarError("SugarCRM API _request returned status code %d" \
% r.status_code)
def get_available_modules(self):
raise SugarError("Method not implemented yet.")
def get_available_modules(self, filter="default"):
"""Retrieves a list of available modules in the system."""
data = [self.session_id, filter]
results = self._request('get_available_modules', data)['modules']
ret = []
for module in results:
m = Module()
for key, value in module.items():
setattr(m, key, value)
ret.append(m)
return ret
def get_document_revision(self):
raise SugarError("Method not implemented yet.")
......@@ -243,14 +252,16 @@ class SugarObject:
class Contact(SugarObject):
module = "Contacts"
class Opportunity(SugarObject):
module = "Opportunities"
class Module(SugarObject):
module = "Modules"
class Note(SugarObject):
module = "Notes"
class Opportunity(SugarObject):
module = "Opportunities"
class SugarError(Exception):
pass
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