Repository: charliequinn/python-litmos-api

Issue:
Help needed to assign a list of users for a course
Hi Charlie,
I am unable to go beyond the code mentioned below

litmos = Litmos({'aXXXXXXXXXXXXX'},{'https://api.litmoseu.com/v1.svc'})

Is there anyway I could directly get the Json file downloaded. Or derive a code to assign course to a list of users 

Thanks in advance.

Regards,
Jins


Discussion:

Patch:
diff --git a/README.rst b/README.rst
index bbcaaf1..4de9b0d 100644
--- a/README.rst
+++ b/README.rst
@@ -56,7 +56,11 @@ Getting started
 .. code-block:: python
 
     from litmos import Litmos
-    litmos = Litmos({apikey}, {source})
+    API_KEY = 'AXXXXXXXXXX'
+    LITMOS_APP_NAME = 'jins.litmos.com'
+    LITMOS_SERVER_URL = 'https://api.litmos.com/v1.svc'  # https://support.litmos.com/hc/en-us/articles/227734667-Overview-Developer-API
+    litmos = Litmos(API_KEY, LITMOS_APP_NAME, LITMOS_SERVER_URL)
+
 
     # --- User ---
     # retrieve users
diff --git a/src/litmos/__init__.py b/src/litmos/__init__.py
index c8637bb..4648d68 100644
--- a/src/litmos/__init__.py
+++ b/src/litmos/__init__.py
@@ -13,9 +13,10 @@ __version__ = "0.6.0"
 class Litmos(object):
     ACCEPTABLE_TYPES = ['User', 'Team', 'Course', 'CourseModule']
 
-    def __init__(self, api_key, app_name):
+    def __init__(self, api_key, app_name, root_url='https://api.litmos.com/v1.svc'):
         API.api_key = api_key
         API.app_name = app_name
+        API.ROOT_URL = root_url
 
         self.litmos_api = API
 
diff --git a/src/litmos/api.py b/src/litmos/api.py
index 77486f6..f4c7032 100644
--- a/src/litmos/api.py
+++ b/src/litmos/api.py
@@ -6,14 +6,14 @@ import requests
 
 
 class API(object):
-    ROOT_URL = 'https://api.litmos.com/v1.svc/'
+    ROOT_URL = 'https://api.litmos.com/v1.svc'
     PAGINATION_OFFSET = 200
     api_key = None
     app_name = None
 
     @classmethod
     def _base_url(cls, resource, **kwargs):
-        return cls.ROOT_URL + \
+        return cls.ROOT_URL + "/" + \
             resource + \
             ("/" + kwargs['resource_id'] if kwargs.get('resource_id', None) else "") + \
             ("/" + kwargs['sub_resource'] if kwargs.get('sub_resource', None) else "") + \


Test patch:
diff --git a/tests/test_litmos_api.py b/tests/test_litmos_api.py
index 4c76140..6286658 100644
--- a/tests/test_litmos_api.py
+++ b/tests/test_litmos_api.py
@@ -14,7 +14,7 @@ class TestLitmosAPI:
         API.app_name = 'app-name-123'
 
     def test_root_url(self):
-        eq_(API.ROOT_URL, 'https://api.litmos.com/v1.svc/')
+        eq_(API.ROOT_URL, 'https://api.litmos.com/v1.svc')
 
     @patch('litmos.api.requests.request')
     def test_all(self, request):