Bug fixes for file_backend, api changes, etc
[doneit] / src / rtm_backend.py
index 8b7549c..4aab70e 100644 (file)
@@ -12,7 +12,7 @@ def fix_url(rturl):
        return "/".join(rturl.split(r"\/"))
 
 
-class RtMilkManager(object):
+class RtmBackend(object):
        """
        Interface with rememberthemilk.com
 
@@ -39,6 +39,38 @@ class RtMilkManager(object):
                self._timeline = resp.timeline
                self._lists = []
 
+       def save(self):
+               pass
+
+       def load(self):
+               pass
+
+       def add_project(self, name):
+               rsp = self._rtm.lists.add(
+                       timeline=self._timeline,
+                       name=name,
+               )
+               assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+               self._lists = []
+
+       def set_project_name(self, projId, name):
+               rsp = self._rtm.lists.setName(
+                       timeline=self._timeline,
+                       list_id=projId,
+                       name=name,
+               )
+               assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+               self._lists = []
+
+       def set_project_visibility(self, projId, visibility):
+               action = self._rtm.lists.unarchive if visibility else self._rtm.lists.archive
+               rsp = action(
+                       timeline=self._timeline,
+                       list_id=projId,
+               )
+               assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+               self._lists = []
+
        def get_projects(self):
                if len(self._lists) == 0:
                        self._populate_projects()
@@ -218,7 +250,7 @@ class RtMilkManager(object):
        @staticmethod
        def _pack_ids(*ids):
                """
-               >>> RtMilkManager._pack_ids(123, 456)
+               >>> RtmBackend._pack_ids(123, 456)
                '123-456'
                """
                return "-".join((str(id) for id in ids))
@@ -226,7 +258,7 @@ class RtMilkManager(object):
        @staticmethod
        def _unpack_ids(ids):
                """
-               >>> RtMilkManager._unpack_ids("123-456")
+               >>> RtmBackend._unpack_ids("123-456")
                ['123', '456']
                """
                return ids.split("-")