Minor updates being taken in from Dialcentral
[doneit] / src / rtm_backend.py
index 8b7549c..f9aa3d6 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,39 @@ 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 = []
+               return rsp.list.id
+
+       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()
@@ -194,6 +227,9 @@ class RtMilkManager(object):
                        note_text=noteBody,
                )
                assert rsp.stat == "ok", "Bad response: %r" % (rsp, )
+               noteId = rsp.note.id
+
+               return self._pack_ids(projId, seriesId, taskId, noteId)
 
        def update_note(self, noteId, noteTitle, noteBody):
                projId, seriesId, taskId, note = self._unpack_ids(noteId)
@@ -218,7 +254,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 +262,7 @@ class RtMilkManager(object):
        @staticmethod
        def _unpack_ids(ids):
                """
-               >>> RtMilkManager._unpack_ids("123-456")
+               >>> RtmBackend._unpack_ids("123-456")
                ['123', '456']
                """
                return ids.split("-")