Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 15, 2011
Thiago Faria de Andrade Adding Task class with some basic methods. 643afdf
Commits on Nov 16, 2011
@jasford jasford Merge pull request #5 from thiagofa/master
Added Task class with basic methods.
f426295
Showing with 76 additions and 4 deletions.
  1. +3 −1 .gitignore
  2. +4 −0 CHANGELOG.md
  3. +1 −1  README.md
  4. +68 −2 pyrise/__init__.py
View
4 .gitignore
@@ -2,4 +2,6 @@
.DS_Store
dist/
build/
-*.egg-info/
+*.egg-info/
+.project
+.pydevproject
View
4 CHANGELOG.md
@@ -1,3 +1,7 @@
+0.4.3
+---
+* Added Task class with some basic methods.
+
0.4.2
---
* Bug fixes
View
2  README.md
@@ -33,12 +33,12 @@ need them.
* Tags
* Notes
* Emails
+* Tasks (partial)
###Not implemented yet:
* Cases
* Comments
-* Tasks
* Users
* Groups
* Memberships
View
70 pyrise/__init__.py
@@ -5,7 +5,7 @@
from datetime import datetime, timedelta
from xml.etree import ElementTree
-__version__ = '0.4.2'
+__version__ = '0.4.3'
class Highrise:
"""Class designed to handle all interactions with the Highrise API."""
@@ -32,7 +32,7 @@ def set_server(cls, server):
@classmethod
def set_timezone_offset(cls, offset):
- """Rather than force pytz or some other time zome library, Pyrise
+ """Rather than force pytz or some other time zone library, Pyrise
works entirely in GMT (as does the Highrise API). Setting this
optional offset value will let you compensate for your local
server timezone, if desired"""
@@ -574,6 +574,72 @@ def delete(self):
"""Delete a deal from Highrise."""
return Highrise.request('/deals/%s.xml' % self.id, method='DELETE')
+
+
+
+class Task(HighriseObject):
+ """An object representing a Highrise task."""
+
+ fields = {
+ 'id': HighriseField(type='id'),
+ 'recording_id': HighriseField(type=int),
+ 'subject_id': HighriseField(type=int),
+ 'subject_type': HighriseField(type=str, options=('Party')),
+ 'category_id': HighriseField(type=int),
+ 'body': HighriseField(type=str),
+ 'frame': HighriseField(type=str, options=('specific')),
+ 'due_at': HighriseField(type=datetime),
+ 'alert_at': HighriseField(type=datetime),
+ 'created_at': HighriseField(type=datetime),
+ 'author_id': HighriseField(type=int),
+ 'updated_at': HighriseField(type=datetime),
+ 'public': HighriseField(type=bool),
+ 'owner_id': HighriseField(type=int),
+ 'notify': HighriseField(type=bool),
+ }
+
+ @classmethod
+ def all(cls):
+ """Get all tasks"""
+
+ return cls._list('tasks.xml', 'task')
+
+ @classmethod
+ def get(cls, id):
+ """Get a single task"""
+
+ # retrieve the task from Highrise
+ xml = Highrise.request('/tasks/%s.xml' % id)
+
+ # return a task object
+ for task_xml in xml.getiterator(tag='task'):
+ return Task.from_xml(task_xml)
+
+ def save(self):
+ """Save a task to Highrise."""
+
+ # get the XML for the request
+ xml = self.save_xml()
+ xml_string = ElementTree.tostring(xml)
+
+ # if this was an initial save, update the object with the returned data
+ if self.id == None:
+ response = Highrise.request('/tasks.xml', method='POST', xml=xml_string)
+ new = Task.from_xml(response)
+
+ # if this was a PUT request, we need to re-request the object
+ # so we can get any new ID values set at ceation
+ else:
+ response = Highrise.request('/tasks/%s.xml' % self.id, method='PUT', xml=xml_string)
+ new = Task.get(self.id)
+
+ # update the values of self to align with what came back from Highrise
+ self.__dict__ = new.__dict__
+
+ def delete(self):
+ """Delete a task from Highrise."""
+
+ return Highrise.request('/tasks/%s.xml' % self.id, method='DELETE')
class ContactData(HighriseObject):

No commit comments for this range

Something went wrong with that request. Please try again.