Permalink
Browse files

Added functions and keys for accessing docspad.

  • Loading branch information...
rajatkhanduja committed Jan 25, 2014
1 parent 84369c8 commit 45945f1cbad17dbc03839388a05cacb0bbf3d07b
Showing with 46 additions and 0 deletions.
  1. +40 −0 hasjob/docspad.py
  2. +3 −0 instance/settings-sample.py
  3. +3 −0 instance/settings.py
View
@@ -0,0 +1,40 @@
import json
import requests
from hasjob import app
'''
Returns the docId when the upload is successful.
Input type is fileobject
'''
def upload(fileobject):
resp = requests.post("http://apis.docspad.com/v1/upload.php", files={'doc':fileobject},
data={'key': app.config['DOCSPAD_CONSUMER_KEY']})
returned_vals = json.loads(resp.text)
if 'error' in returned_vals:
raise Exception(returned_vals['error']['msg'])
else:
return returned_vals['docId']
'''
Returns the status (a dictionary of 'conversion_status' and 'file_status' received from Docspad for the given docId
'''
def get_status(docId):
resp = requests.post("http://apis.docspad.com/v1/status.php", data={'key': app.config['DOCSPAD_CONSUMER_KEY'],
'docId': docId})
returned_vals = json.loads(resp.text)
if 'error' in returned_vals:
raise Exception(returned_vals['error']['msg'])
else:
return returned_vals
'''
Returns the sessionId received from Docspad for the given docId
'''
def get_session(docId):
resp = requests.post("http://apis.docspad.com/v1/session.php", data={'key': app.config['DOCSPAD_CONSUMER_KEY'],
'docId':docId})
returned_vals = json.loads(resp.text)
if 'error' in returned_vals:
raise Exception(returned_vals['error']['msg'])
else:
return returned_vals['sessionId']
@@ -50,3 +50,6 @@
#: Throttle limit for email domain
THROTTLE_LIMIT = 5
SUPPORT_EMAIL = 'person@example.com'
# Consumer key for uploading and accessing documents on Docspad
DOCSPAD_CONSUMER_KEY=''
View
@@ -73,3 +73,6 @@
LASTUSER_CLIENT_ID = ''
#: LastUser client secret
LASTUSER_CLIENT_SECRET = ''
# Consumer key for uploading and accessing documents on Docspad
DOCSPAD_CONSUMER_KEY=''

0 comments on commit 45945f1

Please sign in to comment.