Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added export_group feature #81

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions splitwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Splitwise(object):
"api/"+SPLITWISE_VERSION+"/add_user_to_group"
DELETE_GROUP_URL = SPLITWISE_BASE_URL + \
"api/"+SPLITWISE_VERSION+"/delete_group"
EXPORT_GROUP_URL = SPLITWISE_BASE_URL + \
"api/"+SPLITWISE_VERSION+"/export_group"
GET_COMMENTS_URL = SPLITWISE_BASE_URL + \
"api/"+SPLITWISE_VERSION+"/get_comments"
CREATE_COMMENT_URL = SPLITWISE_BASE_URL + \
Expand Down Expand Up @@ -788,6 +790,27 @@ def deleteGroup(self, id):

return success, errors

def exportGroup(self, id):
""" Exports the group with given id.

Args:
id(long): ID of the group to be exported.

Returns:
string:
The CSV content as string.
"""
try:
content = self.__makeRequest(
Splitwise.EXPORT_GROUP_URL+"/"+str(id), "POST")
except SplitwiseNotAllowedException as e:
e.setMessage("You are not allowed to access group with id %d" % id)
raise
except SplitwiseNotFoundException as e:
e.setMessage("Group with id %d does not exist" % id)
raise
return content

@staticmethod
def setUserArray(users, user_array):
for count, user in enumerate(users):
Expand Down